aboutsummaryrefslogtreecommitdiff
path: root/src/components/search/search.js
diff options
context:
space:
mode:
authorEkaterina Vaartis <vaartis@kotobank.ch>2021-08-22 16:12:36 +0300
committerEkaterina Vaartis <vaartis@kotobank.ch>2021-08-22 16:13:42 +0300
commitb247a917241cd62f1f5f02c5f8c1fab67421f2a9 (patch)
treec0fb3fe4d7c31137b4660ce2de9fe4aee6ebd14b /src/components/search/search.js
parentca7fa67997de81710f96944ccdbd080dcd3b0bf9 (diff)
Ensure uniqueness of found statuses & ensure only one loading circle
Diffstat (limited to 'src/components/search/search.js')
-rw-r--r--src/components/search/search.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/components/search/search.js b/src/components/search/search.js
index 751a9c37..7f64b0f7 100644
--- a/src/components/search/search.js
+++ b/src/components/search/search.js
@@ -7,6 +7,7 @@ import {
faCircleNotch,
faSearch
} from '@fortawesome/free-solid-svg-icons'
+import { uniqBy } from 'lodash'
library.add(
faCircleNotch,
@@ -84,16 +85,20 @@ const Search = {
.then(data => {
this.loading = false
+ let oldLength = this.statuses.length
+
// 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 = this.statuses.concat(data.statuses)
+ this.statuses = uniqBy(this.statuses.concat(data.statuses), 'id')
this.hashtags = this.hashtags.concat(data.hashtags)
this.currenResultTab = this.getActiveTab()
this.loaded = true
- this.statusesOffset += data.statuses.length
- this.lastStatusFetchCount = data.statuses.length
+ // Offset from whatever we already have
+ this.statusesOffset = this.statuses.length
+ // Because the amount of new statuses can actually be zero, compare to old lenght instead
+ this.lastStatusFetchCount = this.statuses.length - oldLength
this.lastQuery = query
})
},