-
Notifications
You must be signed in to change notification settings - Fork 84
Fixed: On successful scan, item get stuck in pending state #818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -283,6 +283,7 @@ const isAnimationInProgress = ref(false); | |
| const productInAnimation = ref({}) as any; | ||
| const isLoadingItems = ref(true); | ||
| const scannedItem = ref({}) as any; | ||
| let scannedItemsQueue = {} as any; | ||
|
|
||
| onIonViewDidEnter(async() => { | ||
| await store.dispatch('count/setCountDetailPageActive', true); | ||
|
|
@@ -531,7 +532,7 @@ async function addProductToItemsList() { | |
| initializeObserver() | ||
| }, 0); | ||
| } | ||
| findProductFromIdentifier(queryString.value.trim(), newItem); | ||
| findProductFromIdentifier(queryString.value.trim(), JSON.parse(JSON.stringify(newItem))); | ||
| return newItem; | ||
| } | ||
|
|
||
|
|
@@ -595,6 +596,13 @@ async function addProductToCount(productId: any) { | |
| return ""; | ||
| } | ||
|
|
||
| // Synchronizes a scanned item with an object, removing it from the scanned items queue. | ||
| function syncScannedItem(updatedItem: any) { | ||
| const scannedId = updatedItem.scannedId; | ||
| if(!scannedId) return updatedItem; | ||
| delete scannedItemsQueue[scannedId]; | ||
| } | ||
|
|
||
| async function updateCurrentItemInList(newItem: any, scannedValue: string) { | ||
| const items = JSON.parse(JSON.stringify(cycleCountItems.value.itemList)); | ||
| const updatedProduct = JSON.parse(JSON.stringify(currentProduct.value)) | ||
|
|
@@ -609,7 +617,11 @@ async function updateCurrentItemInList(newItem: any, scannedValue: string) { | |
| } else if(selectedSegment.value === "unmatched" && (inputCount.value || updatedItem.scannedCount)) { | ||
| newCount = Number(inputCount.value || 0) + Number(updatedItem.scannedCount || 0) | ||
| } | ||
|
|
||
|
|
||
| if(scannedItemsQueue[updatedItem.scannedId]) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This condition |
||
| newCount = scannedItemsQueue[updatedItem.scannedId] | ||
| } | ||
|
|
||
| if(newCount && updatedItem?.importItemSeqId && updatedItem.productId) { | ||
| try { | ||
| const resp = await CountService.updateCount({ | ||
|
|
@@ -630,6 +642,8 @@ async function updateCurrentItemInList(newItem: any, scannedValue: string) { | |
| } | ||
| } | ||
|
|
||
| syncScannedItem(updatedItem); | ||
|
|
||
| if(updatedProduct.scannedId === updatedItem.scannedId) { | ||
| store.dispatch("product/currentProduct", updatedItem); | ||
| } | ||
|
|
@@ -752,6 +766,8 @@ async function saveCount(currentProduct: any, isScrollEvent = false) { | |
| if(selectedCountUpdateType.value === "replace") item.scannedCount = currentCount | ||
| else item.scannedCount = Number(currentCount) + Number(prevCount) | ||
| currentItem = item; | ||
| // Updates the quantity of a scanned item in the scanned items queue. | ||
| scannedItemsQueue[currentProduct.scannedId] = item.scannedCount; | ||
| } | ||
| }) | ||
| await store.dispatch('count/updateCycleCountItems', items); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can be simplified for better clarity and to address the inconsistent return value. It currently returns
updatedItemin one branch but implicitlyundefinedin another. Since the return value is not used, it's best to have no return value for consistency and to signal that the function's purpose is its side effect.