From 049394ccff99c137d37d989a5b2f4e412f4b0f19 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Fri, 27 Nov 2020 13:54:54 +0100 Subject: [PATCH] Fix the All group shifting in localstorage --- resources/js/views/Groups.vue | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/resources/js/views/Groups.vue b/resources/js/views/Groups.vue index 2c882962..a452ade6 100644 --- a/resources/js/views/Groups.vue +++ b/resources/js/views/Groups.vue @@ -51,6 +51,7 @@ data() { return { groups : [], + TheAllGroup : null, } }, @@ -58,7 +59,13 @@ // 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 + // We don't want the pseudo group 'All' to be managed so we shift it + if( groups ) { + this.groups = groups + this.TheAllGroup = this.groups.shift() + } + + // we refresh the collection whatever this.fetchGroups() }, @@ -77,11 +84,11 @@ }) }) + // Remove the pseudo 'All' group + this.TheAllGroup = groups.shift() + this.groups = groups }) - - // Remove the pseudo 'All' group - this.groups.shift() }, deleteGroup(id) { @@ -96,6 +103,7 @@ }, beforeRouteLeave(to, from, next) { + this.groups.unshift(this.TheAllGroup) // Refresh localstorage this.$storage.set('groups', this.groups)