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: [],
|
media: [],
|
||||||
hashtags: [],
|
hashtags: [],
|
||||||
currenResultTab: 'statuses',
|
currenResultTab: 'statuses',
|
||||||
|
preferredTab : 'statuses',
|
||||||
|
|
||||||
statusesOffset: 0,
|
statusesOffset: 0,
|
||||||
lastStatusFetchCount: 0,
|
lastStatusFetchCount: 0,
|
||||||
|
@ -162,17 +163,26 @@ const Search = {
|
||||||
},
|
},
|
||||||
onResultTabSwitch (key) {
|
onResultTabSwitch (key) {
|
||||||
this.currenResultTab = key
|
this.currenResultTab = key
|
||||||
|
this.preferredTab = key
|
||||||
this.loading = false
|
this.loading = false
|
||||||
},
|
},
|
||||||
getActiveTab () {
|
getActiveTab () {
|
||||||
if (this.visibleStatuses.length > 0) {
|
const available = {
|
||||||
return 'statuses'
|
statuses: this.visibleStatuses.length > 0,
|
||||||
} else if (this.visibleMedia.length > 0) {
|
media: this.visibleMedia.length > 0,
|
||||||
return 'media'
|
people: this.users.length > 0,
|
||||||
} else if (this.users.length > 0) {
|
hashtags: this.hashtags.length > 0,
|
||||||
return 'people'
|
}
|
||||||
} else if (this.hashtags.length > 0) {
|
|
||||||
return 'hashtags'
|
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'
|
return 'statuses'
|
||||||
|
|
Loading…
Reference in a new issue