diff options
| author | Ekaterina Vaartis <vaartis@kotobank.ch> | 2021-08-16 21:30:07 +0300 |
|---|---|---|
| committer | Ekaterina Vaartis <vaartis@kotobank.ch> | 2021-08-16 21:46:50 +0300 |
| commit | 3117623f3000eed03ec7828c3ed112bd67366620 (patch) | |
| tree | a8a526b51e73e82501be0f76b6a550b862dd0dac /src/components/search/search.js | |
| parent | 425919a0d292b79869ebefd2a4d52ed4db45d319 (diff) | |
Implement loading more statuses when searching
Diffstat (limited to 'src/components/search/search.js')
| -rw-r--r-- | src/components/search/search.js | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/components/search/search.js b/src/components/search/search.js index b62bc2c5..6347febf 100644 --- a/src/components/search/search.js +++ b/src/components/search/search.js @@ -30,7 +30,11 @@ const Search = { userIds: [], statuses: [], hashtags: [], - currenResultTab: 'statuses' + currenResultTab: 'statuses', + + statusesOffset: 0, + lastStatusFetchCount: 0, + lastQuery: '' } }, computed: { @@ -67,18 +71,26 @@ const Search = { this.loading = true this.userIds = [] - this.statuses = [] this.hashtags = [] this.$refs.searchInput.blur() + if (this.lastQuery !== query) { + this.statuses = [] + this.statusesOffset = 0 + this.lastStatusFetchCount = 0 + } - this.$store.dispatch('search', { q: query, resolve: true }) + this.$store.dispatch('search', { q: query, resolve: true, offset: this.statusesOffset }) .then(data => { this.loading = false this.userIds = map(data.accounts, 'id') - this.statuses = data.statuses + this.statuses = this.statuses.concat(data.statuses) this.hashtags = data.hashtags this.currenResultTab = this.getActiveTab() this.loaded = true + + this.statusesOffset += data.statuses.length + this.lastStatusFetchCount = data.statuses.length + this.lastQuery = query }) }, resultCount (tabName) { |
