fix(bc): sync all pending queue items

This commit is contained in:
Christian Vidal Wolf
2026-05-27 11:14:24 +02:00
parent 8ea63f60c8
commit 97130003d8
2 changed files with 12 additions and 10 deletions
+8 -4
View File
@@ -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 => ({