Fix infiniteLoading state after user add/remove

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2019-02-21 12:02:18 +01:00
parent 10388eab34
commit 6be9fdaa48
No known key found for this signature in database
GPG key ID: 60C25B8C072916CF

View file

@ -206,7 +206,7 @@ export default {
if (disabledUsers.length===0 && this.$refs.infiniteLoading && this.$refs.infiniteLoading.isComplete) {
// disabled group is empty, redirection to all users
this.$router.push({name: 'users'});
this.$refs.infiniteLoading.$emit('$InfiniteLoading:reset');
this.$refs.infiniteLoading.stateChanger.reset()
}
return disabledUsers;
}
@ -253,6 +253,9 @@ export default {
usersLimit() {
return this.$store.getters.getUsersLimit;
},
usersCount() {
return this.users.length
},
/* LANGUAGES */
languages() {
@ -272,8 +275,22 @@ export default {
// watch url change and group select
selectedGroup: function (val, old) {
this.$store.commit('resetUsers');
this.$refs.infiniteLoading.$emit('$InfiniteLoading:reset');
this.$refs.infiniteLoading.stateChanger.reset()
this.setNewUserDefaultGroup(val);
},
// make sure the infiniteLoading state is changed if we manually
// add/remove data from the store
usersCount: function(val, old) {
// deleting the last user, reset the list
if (val === 0 && old === 1) {
this.$refs.infiniteLoading.stateChanger.reset()
// adding the first user, warn the infiniteLoader that
// the list is not empty anymore (we don't fetch the newly
// added user as we already have all the info we need)
} else if (val === 1 && old === 0) {
this.$refs.infiniteLoading.stateChanger.loaded()
}
}
},
methods: {
@ -313,7 +330,7 @@ export default {
search(query) {
this.searchQuery = query;
this.$store.commit('resetUsers');
this.$refs.infiniteLoading.$emit('$InfiniteLoading:reset');
this.$refs.infiniteLoading.stateChanger.reset()
},
resetSearch() {
this.search('');
@ -336,7 +353,9 @@ export default {
quota: this.newUser.quota.id,
language: this.newUser.language.code,
})
.then(() => this.resetForm())
.then(() => {
this.resetForm()
})
.catch((error) => {
this.loading.all = false;
if (error.response && error.response.data && error.response.data.ocs && error.response.data.ocs.meta) {