Compare commits
2 commits
c578846b98
...
d5c74cccbd
Author | SHA1 | Date | |
---|---|---|---|
d5c74cccbd | |||
92aa58356b |
2 changed files with 16 additions and 1 deletions
|
@ -29,6 +29,7 @@ const Search = {
|
|||
],
|
||||
data () {
|
||||
return {
|
||||
queryCount: 0,
|
||||
loadedInitially: false,
|
||||
loading: Object.fromEntries(
|
||||
allSearchTypes.map((searchType) => [searchType, false])
|
||||
|
@ -105,6 +106,8 @@ const Search = {
|
|||
return
|
||||
}
|
||||
|
||||
const localQueryCount = ++this.queryCount
|
||||
|
||||
const isNewSearch = this.lastQuery !== query
|
||||
this.$refs.searchInput.blur()
|
||||
if (isNewSearch) {
|
||||
|
@ -162,6 +165,11 @@ const Search = {
|
|||
local: 'localOnly' in this.filter && this.filter.localOnly
|
||||
})
|
||||
|
||||
if (localQueryCount !== this.queryCount) {
|
||||
// Query count differs, there should be a newer query
|
||||
return
|
||||
}
|
||||
|
||||
// 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,6 +190,11 @@ const Search = {
|
|||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
if (localQueryCount !== this.queryCount) {
|
||||
// Skip cleanups if there's a newer query
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.loadedInitially && this.hasAtLeastOneResult) {
|
||||
// Show results on the first meaningful response
|
||||
this.loadedInitially = true
|
||||
|
|
|
@ -51,7 +51,9 @@ const SearchBar = {
|
|||
event.isComposing ||
|
||||
event.metaKey ||
|
||||
event.repeat ||
|
||||
event.shiftKey
|
||||
event.shiftKey ||
|
||||
// not very vue-esque, but as long as it works
|
||||
document.querySelector('.modal-view.modal-background.open')
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue