From 681e323e412071b970d2b887d68d6f78958fb077 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 14 Mar 2024 11:55:09 +0530 Subject: [PATCH] Improved: code to clear lastScannedId from state on picklist change and logout, removed unused getter (#198) --- src/components/Picklist-item.vue | 1 + src/views/Picklist-Detail.vue | 4 ++-- src/views/Settings.vue | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/Picklist-item.vue b/src/components/Picklist-item.vue index 61543ab..3074b12 100644 --- a/src/components/Picklist-item.vue +++ b/src/components/Picklist-item.vue @@ -25,6 +25,7 @@ export default defineComponent({ props: ['picklists'], methods: { async viewPicklist (picklist: any) { + this.store.dispatch("picklist/updateLastScannedId", "") // if current is not set promise.reject returns which will not allow further code execution // and hence, router.push will not execute stopping the code from breaking await this.store.dispatch('picklist/setCurrentPicklist', { id: picklist.picklistId }) diff --git a/src/views/Picklist-Detail.vue b/src/views/Picklist-Detail.vue index 59356bc..c918a56 100644 --- a/src/views/Picklist-Detail.vue +++ b/src/views/Picklist-Detail.vue @@ -122,8 +122,7 @@ export default defineComponent({ computed: { ...mapGetters({ picklist: 'picklist/getCurrent', - picklistItemSortBy: 'user/getPicklistItemSortBy', - lastScannedId: 'picklist/getLastScannedId', + picklistItemSortBy: 'user/getPicklistItemSortBy' }) }, data() { @@ -190,6 +189,7 @@ export default defineComponent({ const scannedElement = document.getElementById(item.id); scannedElement && (scannedElement.scrollIntoView()); + // Scanned product should get un-highlighted after 3s for better experience hence adding setTimeOut setTimeout(() => { this.store.dispatch("picklist/updateLastScannedId", "") }, 3000) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 2c793fe..0d211d3 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -157,6 +157,7 @@ export default defineComponent({ logout () { this.store.dispatch('user/logout', { isUserUnauthorised: false }).then((redirectionUrl) => { this.store.dispatch('picklist/clearPicklist') + this.store.dispatch("picklist/updateLastScannedId", "") // if not having redirection url then redirect the user to launchpad if(!redirectionUrl) {