diff --git a/src/views/CountDetail.vue b/src/views/CountDetail.vue index 4932e59e..4b186edc 100644 --- a/src/views/CountDetail.vue +++ b/src/views/CountDetail.vue @@ -305,8 +305,8 @@ onIonViewDidEnter(async() => { previousItem = itemsList.value[0] await store.dispatch("product/currentProduct", itemsList.value[0]) barcodeInput.value?.$el?.setFocus(); - initializeObserver() emitter.emit("dismissLoader") + if(itemsList.value?.length) initializeObserver() }) onIonViewDidLeave(async() => { @@ -442,7 +442,7 @@ async function updateFilteredItems() { store.dispatch("product/currentProduct", {}); } await nextTick(); - initializeObserver() + if(itemsList.value?.length) initializeObserver() } function initializeObserver() { diff --git a/src/views/HardCountDetail.vue b/src/views/HardCountDetail.vue index d3d2e771..df4359f5 100644 --- a/src/views/HardCountDetail.vue +++ b/src/views/HardCountDetail.vue @@ -262,8 +262,8 @@ onIonViewDidEnter(async() => { barcodeInputRef.value?.$el?.setFocus(); selectedCountUpdateType.value = defaultRecountUpdateBehaviour.value window.addEventListener('beforeunload', handleBeforeUnload); - initializeObserver() emitter.emit("dismissLoader") + if(itemsList.value?.length) initializeObserver() }) onIonViewDidLeave(async() => { @@ -328,7 +328,7 @@ async function handleSegmentChange() { inputCount.value = "" selectedCountUpdateType.value = defaultRecountUpdateBehaviour.value await nextTick(); - initializeObserver() + if(itemsList.value?.length) initializeObserver() } async function changeProduct(direction: string) { @@ -430,7 +430,11 @@ async function addProductToItemsList() { const items = JSON.parse(JSON.stringify(cycleCountItems.value.itemList)) items.push(newItem); await store.dispatch("count/updateCycleCountItems", items); - initializeObserver() + if(itemsList.value?.length) { + setTimeout(() => { + initializeObserver() + }, 0); + } findProductFromIdentifier(queryString.value.trim()); return newItem; }