Skip to content
Snippets Groups Projects
Commit b247a917 authored by vaartis's avatar vaartis
Browse files

Ensure uniqueness of found statuses & ensure only one loading circle

parent ca7fa679
No related branches found
No related tags found
2 merge requests!1711Update stable - 2.5.0 release,!1410Implement loading more statuses when searching
......@@ -7,6 +7,7 @@ import {
faCircleNotch,
faSearch
} from '@fortawesome/free-solid-svg-icons'
import { uniqBy } from 'lodash'
library.add(
faCircleNotch,
......@@ -84,16 +85,20 @@ const Search = {
.then(data => {
this.loading = false
let oldLength = this.statuses.length
// 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.statuses = uniqBy(this.statuses.concat(data.statuses), 'id')
this.hashtags = this.hashtags.concat(data.hashtags)
this.currenResultTab = this.getActiveTab()
this.loaded = true
this.statusesOffset += data.statuses.length
this.lastStatusFetchCount = data.statuses.length
// Offset from whatever we already have
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
})
},
......
......@@ -22,7 +22,7 @@
</button>
</div>
<div
v-if="loading"
v-if="loading && statusesOffset == 0"
class="text-center loading-icon"
>
<FAIcon
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment