From 97130003d811edbbafcb94bb1596643a1d380dbe Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Wed, 27 May 2026 11:14:24 +0200 Subject: [PATCH] fix(bc): sync all pending queue items --- src/App.tsx | 12 ++++++++---- src/components/TopBar.tsx | 10 ++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index b74906c..081a0e2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -792,22 +792,26 @@ export default function App() { }; const handleSyncSelectedBcSync = async () => { - if (selectedBcQueueEntries.length === 0) return; + if (bcQueueEntries.length === 0) return; setIsSyncingBC(true); try { - const selectedArticles = new Set(selectedBcQueueEntries.map(([articleNo]) => articleNo)); + const entriesToSync = [...bcQueueEntries].sort((a, b) => { + const rowDelta = a[1].rowIndex - b[1].rowIndex; + if (rowDelta !== 0) return rowDelta; + return a[0].localeCompare(b[0]); + }); setBcSyncQueue(prev => { const next: BcSyncQueue = { ...prev }; (Object.entries(next) as Array<[string, BcSyncQueueEntry]>).forEach(([articleNo, item]) => { - if (selectedArticles.has(articleNo)) { + if (next[articleNo]) { next[articleNo] = { ...item, status: 'syncing', error: undefined }; } }); return next; }); - for (const [articleNo, item] of selectedBcQueueEntries) { + for (const [articleNo, item] of entriesToSync) { const preview = await previewBusinessCentralSync(appState.headers, item.newData); if (!preview.success) { setBcSyncQueue(prev => ({ diff --git a/src/components/TopBar.tsx b/src/components/TopBar.tsx index 7db8943..4af459c 100644 --- a/src/components/TopBar.tsx +++ b/src/components/TopBar.tsx @@ -196,10 +196,10 @@ export function TopBar({ stats, activeModule, onRefresh, userEmail, onSignOut, c )}>