Please don't switch tabs left and right when searching
This commit is contained in:
parent
7042d0f4b6
commit
a4915a6501
1 changed files with 18 additions and 8 deletions
|
@ -36,6 +36,7 @@ const Search = {
|
|||
media: [],
|
||||
hashtags: [],
|
||||
currenResultTab: 'statuses',
|
||||
preferredTab : 'statuses',
|
||||
|
||||
statusesOffset: 0,
|
||||
lastStatusFetchCount: 0,
|
||||
|
@ -162,17 +163,26 @@ const Search = {
|
|||
},
|
||||
onResultTabSwitch (key) {
|
||||
this.currenResultTab = key
|
||||
this.preferredTab = key
|
||||
this.loading = false
|
||||
},
|
||||
getActiveTab () {
|
||||
if (this.visibleStatuses.length > 0) {
|
||||
return 'statuses'
|
||||
} else if (this.visibleMedia.length > 0) {
|
||||
return 'media'
|
||||
} else if (this.users.length > 0) {
|
||||
return 'people'
|
||||
} else if (this.hashtags.length > 0) {
|
||||
return 'hashtags'
|
||||
const available = {
|
||||
statuses: this.visibleStatuses.length > 0,
|
||||
media: this.visibleMedia.length > 0,
|
||||
people: this.users.length > 0,
|
||||
hashtags: this.hashtags.length > 0,
|
||||
}
|
||||
|
||||
if (available[this.preferredTab]) {
|
||||
return this.preferredTab
|
||||
}
|
||||
|
||||
const tabOrder = ['statuses', 'media', 'people', 'hashtags']
|
||||
for (const tab of tabOrder) {
|
||||
if (available[tab]) {
|
||||
return tab
|
||||
}
|
||||
}
|
||||
|
||||
return 'statuses'
|
||||
|
|
Loading…
Reference in a new issue