diff --git a/frontend/dashboard.js b/frontend/dashboard.js index ef21b86..3dac5f5 100644 --- a/frontend/dashboard.js +++ b/frontend/dashboard.js @@ -417,7 +417,7 @@ const draftInbox = createDraftInbox({ storage: localStorage, getCurrentLogin: () => activeFlushLogin }); outboxCoordinator.subscribe(() => refreshMyWorkView()); const offlineWorkStore = createOfflineWorkStore({ storage: localStorage, indexedDB:window.indexedDB }); - await offlineWorkStore.ready(); + let offlineStorageReady = await offlineWorkStore.ready(); function renderOfflineTodayStatus(status) { const container = qs('#offline-today-readiness'); const label = qs('#offline-today-status'); @@ -4735,12 +4735,16 @@ const offlineStatus = qs('#offline-status'); const keepWorkOffline = qs('#keep-work-offline'); const offlineWorkStatus = qs('#offline-work-status'); + const retryOfflineStorage = qs('#retry-offline-storage'); const deliveryReceipts = qs('#delivery-receipts'); const deliveryReceiptStatus = qs('#delivery-receipt-status'); async function updateOfflineWorkControls(message) { keepWorkOffline.checked = offlineWorkStore.enabled(); + keepWorkOffline.disabled = !offlineStorageReady; + retryOfflineStorage.hidden = offlineStorageReady; const saved = await offlineWorkStore.load(); - offlineWorkStatus.textContent = message || (saved ? 'Saved ' + fmt(saved.saved_at) + ' · expires after 7 days.' : + offlineWorkStatus.textContent = message || (!offlineStorageReady ? + 'Offline saving unavailable · online work remains live.' : saved ? 'Saved ' + fmt(saved.saved_at) + ' · expires after 7 days.' : (keepWorkOffline.checked ? 'Waiting for a healthy live refresh.' : 'Off · no work data is stored.')); } async function updateDeliveryReceiptControls(message) { @@ -4848,6 +4852,18 @@ renderOfflineTodayStatus({ total:0, ready:0, failed:0, pending:0 }); await updateOfflineWorkControls('Offline work data cleared.'); }); + retryOfflineStorage.addEventListener('click', async () => { + retryOfflineStorage.disabled = true; + offlineWorkStatus.textContent = 'Retrying offline saving…'; + offlineStorageReady = await offlineWorkStore.retry(); + retryOfflineStorage.disabled = false; + if (offlineStorageReady && offlineWorkStore.enabled() && liveMode && lastContextSnapshot) { + await offlineWorkStore.save({ ...lastContextSnapshot, notifications:lastNotifications, + notification_pagination:notificationPagination }); + } + await updateOfflineWorkControls(offlineStorageReady ? 'Offline saving restored.' : + 'Offline saving unavailable · online work remains live.'); + }); qs('#retry-offline-today').addEventListener('click', () => offlineToday.retry(confirmedOwnerLogin, todayMyWork) ); diff --git a/frontend/index.html b/frontend/index.html index 321f547..aa6e239 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -98,6 +98,7 @@ +