From 410042e68abcc4bb42f26641ed63e6600274e810 Mon Sep 17 00:00:00 2001 From: Ridwa Date: Tue, 9 Jul 2024 19:37:37 +0530 Subject: [PATCH] Fixed: state not updating in case of no record for fetching users (#149) --- src/store/modules/user/actions.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 23fdd70..9f2c335 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -346,16 +346,17 @@ const actions: ActionTree = { "viewSize": payload.viewSize } - let users = JSON.parse(JSON.stringify(state.users.list)), total = 0; + const users = JSON.parse(JSON.stringify(state.users.list)); + let total = 0 , usersList = [] as any; try { const resp = await UserService.fetchUsers(params); if (!hasError(resp) && resp.data.count) { if (payload.viewIndex && payload.viewIndex > 0) { - users = users.concat(resp.data.docs); + usersList = users.concat(resp.data.docs); } else { - users = resp.data.docs; + usersList = resp.data.docs; } total = resp.data.count; } else { @@ -366,7 +367,7 @@ const actions: ActionTree = { } emitter.emit("dismissLoader"); - commit(types.USER_LIST_UPDATED, { users, total }); + commit(types.USER_LIST_UPDATED, { users: usersList, total }); }, updateQuery({ commit }, query) {