Update frontend/composables/use-shopping-list-item-actions.ts

Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
This commit is contained in:
Craig Matear 2025-06-09 20:12:10 +01:00 committed by GitHub
commit 4f23153dae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -95,12 +95,12 @@ export function useShoppingListItemActions(shoppingListId: string) {
) { ) {
const mergedList = [...list1]; const mergedList = [...list1];
list2.forEach((list2Item) => { list2.forEach((list2Item) => {
const confictingItem = mergedList.find((item) => item.id === list2Item.id) const conflictingItem = mergedList.find((item) => item.id === list2Item.id)
if (confictingItem && if (conflictingItem &&
list2Item.updatedAt && confictingItem.updatedAt && list2Item.updatedAt && conflictingItem.updatedAt &&
list2Item.updatedAt > confictingItem.updatedAt) { list2Item.updatedAt > conflictingItem.updatedAt) {
mergedList.splice(mergedList.indexOf(confictingItem), 1, list2Item) mergedList.splice(mergedList.indexOf(conflictingItem), 1, list2Item)
} else if (!confictingItem) { } else if (!conflictingItem) {
mergedList.push(list2Item) mergedList.push(list2Item)
} }
}) })