From 3afad745796942b2ac1755af72d7aaf1a6e5fe52 Mon Sep 17 00:00:00 2001 From: itepechi <72330683+itepechi@users.noreply.github.com> Date: Mon, 6 Nov 2023 07:44:00 +0900 Subject: [PATCH] Refactor search component --- src/components/search/search.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/search/search.js b/src/components/search/search.js index 71d2f68f..de7578c4 100644 --- a/src/components/search/search.js +++ b/src/components/search/search.js @@ -153,13 +153,6 @@ const Search = { 'followingOnly' in this.filter && this.filter.followingOnly }) - for (const value of Object.values(data)) { - if (value.length) { - this.loading = false - break - } - } - // Always append to old results. If new results are empty, this doesn't change anything this.userIds = this.userIds.concat(map(data.accounts, 'id')) this.statuses = uniqBy(this.statuses.concat(data.statuses), 'id') @@ -182,11 +175,20 @@ const Search = { this.statusesOffset = this.statuses.length // Because the amount of new statuses can actually be zero, compare to old length instead this.lastStatusFetchCount = this.statuses.length - oldStatusesLength - } - if (searchType === 'media') { + } else if (searchType === 'media') { this.mediaOffset = this.media.length this.lastMediaFetchCount = this.media.length - oldMediaLength } + + if (searchTypes.length > 1) { + for (const value of Object.values(data)) { + if (value.length) { + // Show results on the first meaningful response + this.loading = false + break + } + } + } } this.lastQuery = query