From ffe9271bcf81927399867c3158de8f64a93a213c Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Tue, 2 Mar 2021 20:27:50 +0100 Subject: [PATCH] Add fetch method for PlatformUser --- src/scripts/classes/post.ts | 5 +++-- src/scripts/classes/thread.ts | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/scripts/classes/post.ts b/src/scripts/classes/post.ts index d2a1718..f83bb45 100644 --- a/src/scripts/classes/post.ts +++ b/src/scripts/classes/post.ts @@ -90,7 +90,7 @@ export default class Post { }); // Finally parse the post - this.parsePost($, $(post)); + await this.parsePost($, $(post)); } else throw htmlResponse.value; } @@ -98,7 +98,7 @@ export default class Post { //#region Private methods - private parsePost($: cheerio.Root, post: cheerio.Cheerio): void { + private async parsePost($: cheerio.Root, post: cheerio.Cheerio): Promise { // Find post's ID const sid: string = post.find(POST.ID).attr("id").replace("post-", ""); this._id = parseInt(sid); @@ -117,6 +117,7 @@ export default class Post { // Find post's owner this._owner = new PlatformUser(0); + await this._owner.fetch(); // Find if the post is bookmarked this._bookmarked = post.find(POST.BOOKMARKED).length !== 0; diff --git a/src/scripts/classes/thread.ts b/src/scripts/classes/thread.ts index c72b5ce..7d137f3 100644 --- a/src/scripts/classes/thread.ts +++ b/src/scripts/classes/thread.ts @@ -228,6 +228,7 @@ export default class Thread { this._tags = tagArray.map(el => $(el).text().trim()); this._prefixes = prefixArray.map(el => $(el).text().trim()); this._owner = new PlatformUser(parseInt(ownerID)); + await this._owner.fetch(); this._rating = this.parseRating(JSONLD); this._category = JSONLD["articleSection"] as TCategory;