From b841da19c08bdfa8eb1bf41fe9e2ddf00adc2e56 Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Wed, 10 Mar 2021 11:47:21 +0100 Subject: [PATCH] Fix async elaborateResponse --- src/scripts/classes/mapping/platform-user.ts | 2 +- src/scripts/classes/mapping/post.ts | 4 ++-- src/scripts/classes/mapping/thread.ts | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/scripts/classes/mapping/platform-user.ts b/src/scripts/classes/mapping/platform-user.ts index 3e2d127..0817805 100644 --- a/src/scripts/classes/mapping/platform-user.ts +++ b/src/scripts/classes/mapping/platform-user.ts @@ -158,7 +158,7 @@ export default class PlatformUser implements ILazy { // Fetch the page const response = await fetchHTML(url); - const result = response.applyOnSuccess(this.elaborateResponse); + const result = response.applyOnSuccess((html) => this.elaborateResponse(html)); if (result.isFailure()) throw response.value; } diff --git a/src/scripts/classes/mapping/post.ts b/src/scripts/classes/mapping/post.ts index 57b992b..1d3f59c 100644 --- a/src/scripts/classes/mapping/post.ts +++ b/src/scripts/classes/mapping/post.ts @@ -108,8 +108,8 @@ export default class Post implements ILazy { const url = new URL(this.id.toString(), urls.POSTS).toString(); const response = await fetchHTML(url); - const result = response.applyOnSuccess(this.elaborateResponse); - if (result.isFailure()) throw response.value; + if (response.isSuccess()) await this.elaborateResponse(response.value); + else throw response.value; } //#endregion Public methods diff --git a/src/scripts/classes/mapping/thread.ts b/src/scripts/classes/mapping/thread.ts index ca583c1..5ea3d43 100644 --- a/src/scripts/classes/mapping/thread.ts +++ b/src/scripts/classes/mapping/thread.ts @@ -244,10 +244,8 @@ export default class Thread implements ILazy { // Fetch the HTML source const response = await fetchHTML(this.url); - const result = response.applyOnSuccess( - async (html) => await this.elaborateResponse(html) - ); - if (result.isFailure()) throw result.value; + if (response.isSuccess()) await this.elaborateResponse(response.value); + else throw response.value; } /**