Ensure uniqueness of found statuses & ensure only one loading circle
This commit is contained in:
parent
ca7fa67997
commit
b247a91724
|
@ -7,6 +7,7 @@ import {
|
||||||
faCircleNotch,
|
faCircleNotch,
|
||||||
faSearch
|
faSearch
|
||||||
} from '@fortawesome/free-solid-svg-icons'
|
} from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { uniqBy } from 'lodash'
|
||||||
|
|
||||||
library.add(
|
library.add(
|
||||||
faCircleNotch,
|
faCircleNotch,
|
||||||
|
@ -84,16 +85,20 @@ const Search = {
|
||||||
.then(data => {
|
.then(data => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
|
||||||
|
let oldLength = this.statuses.length
|
||||||
|
|
||||||
// Always append to old results. If new results are empty, this doesn't change anything
|
// 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.userIds = this.userIds.concat(map(data.accounts, 'id'))
|
||||||
this.statuses = this.statuses.concat(data.statuses)
|
this.statuses = uniqBy(this.statuses.concat(data.statuses), 'id')
|
||||||
this.hashtags = this.hashtags.concat(data.hashtags)
|
this.hashtags = this.hashtags.concat(data.hashtags)
|
||||||
|
|
||||||
this.currenResultTab = this.getActiveTab()
|
this.currenResultTab = this.getActiveTab()
|
||||||
this.loaded = true
|
this.loaded = true
|
||||||
|
|
||||||
this.statusesOffset += data.statuses.length
|
// Offset from whatever we already have
|
||||||
this.lastStatusFetchCount = data.statuses.length
|
this.statusesOffset = this.statuses.length
|
||||||
|
// Because the amount of new statuses can actually be zero, compare to old lenght instead
|
||||||
|
this.lastStatusFetchCount = this.statuses.length - oldLength
|
||||||
this.lastQuery = query
|
this.lastQuery = query
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="loading"
|
v-if="loading && statusesOffset == 0"
|
||||||
class="text-center loading-icon"
|
class="text-center loading-icon"
|
||||||
>
|
>
|
||||||
<FAIcon
|
<FAIcon
|
||||||
|
|
Loading…
Reference in New Issue