mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-15 16:22:25 +02:00
Reduce data display latency using localstorage
This commit is contained in:
@ -55,7 +55,10 @@
|
||||
},
|
||||
|
||||
mounted() {
|
||||
|
||||
// Load groups for localstorage at first to avoid latency
|
||||
const groups = this.$storage.get('groups', null) // use null as fallback if localstorage is empty
|
||||
|
||||
if( groups ) this.groups = groups
|
||||
this.fetchGroups()
|
||||
},
|
||||
|
||||
@ -64,13 +67,17 @@
|
||||
async fetchGroups() {
|
||||
|
||||
await this.axios.get('api/groups').then(response => {
|
||||
const groups = []
|
||||
|
||||
response.data.forEach((data) => {
|
||||
this.groups.push({
|
||||
groups.push({
|
||||
id : data.id,
|
||||
name : data.name,
|
||||
count: data.twofaccounts_count
|
||||
})
|
||||
})
|
||||
|
||||
this.groups = groups
|
||||
})
|
||||
|
||||
// Remove the pseudo 'All' group
|
||||
@ -88,5 +95,12 @@
|
||||
|
||||
},
|
||||
|
||||
beforeRouteLeave(to, from, next) {
|
||||
// Refresh localstorage
|
||||
this.$storage.set('groups', this.groups)
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
Reference in New Issue
Block a user