diff options
| author | Ekaterina Vaartis <vaartis@kotobank.ch> | 2021-08-22 15:36:03 +0300 |
|---|---|---|
| committer | Ekaterina Vaartis <vaartis@kotobank.ch> | 2021-08-22 15:53:20 +0300 |
| commit | ca7fa67997de81710f96944ccdbd080dcd3b0bf9 (patch) | |
| tree | 7a64daa266bb74eadcba0287d626f6b2232915a6 /src | |
| parent | 3117623f3000eed03ec7828c3ed112bd67366620 (diff) | |
Amend status search results, and introduce searchType
Use searchType to only search for statuses when searching for more results
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/search/search.js | 16 | ||||
| -rw-r--r-- | src/components/search/search.vue | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/components/search/search.js b/src/components/search/search.js index 6347febf..751a9c37 100644 --- a/src/components/search/search.js +++ b/src/components/search/search.js @@ -63,28 +63,32 @@ const Search = { this.$router.push({ name: 'search', query: { query } }) this.$refs.searchInput.focus() }, - search (query) { + search (query, searchType = null) { if (!query) { this.loading = false return } this.loading = true - this.userIds = [] - this.hashtags = [] this.$refs.searchInput.blur() if (this.lastQuery !== query) { + this.userIds = [] + this.hashtags = [] this.statuses = [] + this.statusesOffset = 0 this.lastStatusFetchCount = 0 } - this.$store.dispatch('search', { q: query, resolve: true, offset: this.statusesOffset }) + this.$store.dispatch('search', { q: query, resolve: true, offset: this.statusesOffset, 'type': searchType }) .then(data => { this.loading = false - this.userIds = map(data.accounts, 'id') + + // 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.hashtags = data.hashtags + this.hashtags = this.hashtags.concat(data.hashtags) + this.currenResultTab = this.getActiveTab() this.loaded = true diff --git a/src/components/search/search.vue b/src/components/search/search.vue index 5d8a6715..f3076f65 100644 --- a/src/components/search/search.vue +++ b/src/components/search/search.vue @@ -68,7 +68,7 @@ <button v-if="!loading && loaded && lastStatusFetchCount > 0" class="more-statuses-button button-unstyled -link -fullwidth" - @click.prevent="search(searchTerm)" + @click.prevent="search(searchTerm, 'statuses')" > <div class="new-status-notification text-center"> {{ $t('search.load_more') }} |
