Skip to content
Snippets Groups Projects
Verified Commit ac0c1838 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Fixed some loading issues

parent 9ca2dfff
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@
<img v-if="account._source.getAvatar(account)" :src="account._source.getAvatar(account)" alt="" class="circle">
<span class="title">{{ account._source.getDisplayName(account) }}</span>
<p>{{ account._source.label }}</p>
<div v-if="isLoading && results[account.id] && results[account.id].results.isLoading">
<div v-if="isLoadingSources && results[account.id] && results[account.id].results.isLoading">
<div class="progress">
<div v-if="results[account.id].results.progress === 'indeterminate'" :class="indeterminate"></div>
<div v-else class="determinate" :style="{width: `${results[account.id].results.progress}%`}"></div>
......@@ -68,11 +68,15 @@ import axios from 'axios'
export default {
data () {
return {
isLoading: false,
isLoadingSources: false,
isLoadingRetribute: false,
results: {},
aggregatedSuggestions: this.$store.state.cache.aggregatedSuggestions || {},
retributeProfiles: this.$store.state.cache.retributeProfiles || {},
loadingRetributeProfiles: [],
filters: {
retributeOnly: true
}
}
},
computed: {
......@@ -82,18 +86,33 @@ export default {
return a
})
},
allSuggestions () {
return Object.values(this.aggregatedSuggestions)
},
filteredSuggestions () {
return orderBy(Object.values(this.aggregatedSuggestions), ['weight', 'id'], ['desc', 'asc'])
let self = this
let suggestions = this.allSuggestions.filter((s) => {
let f = true
if (self.filters.retributeOnly) {
f = !!this.retributeProfiles[s.fullId]
}
return f
})
return orderBy(suggestions, ['weight', 'id'], ['desc', 'asc'])
},
missingRetributeProfiles () {
return this.filteredSuggestions.filter((s) => {
return this.allSuggestions.filter((s) => {
return this.retributeProfiles[s.fullId] === undefined
})
},
isLoading () {
return this.isLoadingSources || this.isLoadingRetribute
}
},
methods: {
clearCache () {
this.isLoading = false
this.isLoadingSources = false
this.isLoadingRetribute = false
this.results = {}
this.aggregatedSuggestions = {}
this.retributeProfiles = {}
......@@ -129,7 +148,7 @@ export default {
this.retributeProfiles = {}
this.loadingRetributeProfiles = []
}
this.isLoading = true
this.isLoadingSources = true
accounts.forEach((a) => {
let r = {isLoading: true, progress: 'indeterminate', status: ''}
let promise = a._source.fetch({account: a, store: this.$store, results: r, vue: this})
......@@ -139,15 +158,18 @@ export default {
for(let i = 0; i < keys.length; i++){
await this.results[keys[i]].promise
}
this.isLoading = false
this.isLoadingSources = false
},
async lookupAll () {
this.isLoading = true
const chunkSize = 10
let self = this
const toLoad = this.missingRetributeProfiles.filter((p) => {
return self.loadingRetributeProfiles.indexOf(p.fullId) === -1
})
if (toLoad.length === 0) {
return
}
this.isLoadingRetribute = true
const chunkSize = 10
// lock
toLoad.forEach((p) => {
self.loadingRetributeProfiles.push(p.fullId)
......@@ -160,7 +182,7 @@ export default {
})
await this.lookups(ids)
}
this.isLoading = false
this.isLoadingRetribute = false
},
async lookups(ids) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment