From 58c1f046095349990b7539c327a19bd235f21ebe Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Fri, 28 Aug 2020 21:35:50 -0400 Subject: [PATCH] more resilient status search --- src/app/services/tools.service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/services/tools.service.ts b/src/app/services/tools.service.ts index 7aa3426d..2e68a03f 100644 --- a/src/app/services/tools.service.ts +++ b/src/app/services/tools.service.ts @@ -224,12 +224,17 @@ export class ToolsService { if (!isProvider) { statusPromise = statusPromise .then((foreignStatus: Status) => { - const statusUrl = foreignStatus.url; + const statusUri = foreignStatus.uri; + const statusUrl = foreignStatus.url; return this.getInstanceInfo(account) .then(instance => { let version: 'v1' | 'v2' = 'v1'; if (instance.major >= 3) version = 'v2'; - return this.mastodonService.search(account, statusUrl, version, true); + return this.mastodonService.search(account, statusUri, version, true) + .then((results: Results) => { + if(results && results.statuses.length > 0) return results; + return this.mastodonService.search(account, statusUrl, version, true); + }); }) .then((results: Results) => { return results.statuses[0];