fix: flush durable outboxes after reconnect (Closes #927)
This commit is contained in:
1 parent
76eed47487
commit
64e764b996
6 files changed
+92
-7
No files matched your search
+13
-7
@@ -6962,19 +6962,25 @@
|
||||
setStatus('Offline');
|
||||
if (!hasContextSnapshot) await hydrateOfflineWork();
|
||||
}
|
||||
function reconnectLiveData() {
|
||||
setStatus('Reconnecting…');
|
||||
contextPoller.refresh({ force: true }).then(snapshot => {
|
||||
const reconnectOutboxes = createReconnectOutboxes({
|
||||
refresh: async () => {
|
||||
setStatus('Reconnecting…');
|
||||
const snapshot = await contextPoller.refresh({ force: true });
|
||||
if (!snapshot) {
|
||||
offlineStatus.hidden = false;
|
||||
setOfflineWorkMode(true);
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
offlineStatus.hidden = true;
|
||||
setOfflineWorkMode(false);
|
||||
if (selectedReview && offlineReview) openReviewSheet(selectedReview, reviewTrigger);
|
||||
});
|
||||
}
|
||||
return snapshot;
|
||||
},
|
||||
restoreIdentity: login => { activeFlushLogin = login; confirmedOwnerLogin = login; },
|
||||
flushIssue: flushIssueOutbox,
|
||||
flushAuthored: flushAuthoredOutbox,
|
||||
flushNotificationReads: flushNotificationReadOutbox,
|
||||
});
|
||||
async function setOfflineWorkEnabled(enabled) {
|
||||
keepWorkOffline.checked = enabled;
|
||||
offlineWorkStore.setEnabled(enabled);
|
||||
@@ -7032,7 +7038,7 @@
|
||||
updateDeliveryReceiptControls();
|
||||
if (!navigator.onLine) await showOfflineStatus();
|
||||
window.addEventListener('offline', showOfflineStatus);
|
||||
window.addEventListener('online', reconnectLiveData);
|
||||
window.addEventListener('online', reconnectOutboxes);
|
||||
|
||||
qs('#refresh').addEventListener('click', load);
|
||||
qs('#plan-today').addEventListener('click', event => openPlanToday(event.currentTarget));
|
||||
|
||||
@@ -1307,6 +1307,7 @@
|
||||
<script src="static/outbox-coordinator.js"></script>
|
||||
<script src="static/background-issue-sync.js"></script>
|
||||
<script src="static/issue-outbox.js"></script>
|
||||
<script src="static/reconnect-outboxes.js"></script>
|
||||
<script src="static/authored-outbox.js"></script>
|
||||
<script src="static/offline-issue-close.js"></script>
|
||||
<script src="static/offline-issue-blocker.js"></script>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
function createReconnectOutboxes({
|
||||
refresh,
|
||||
restoreIdentity,
|
||||
flushIssue,
|
||||
flushAuthored,
|
||||
flushNotificationReads,
|
||||
}) {
|
||||
return async function reconnectOutboxes() {
|
||||
const snapshot = await refresh();
|
||||
const freshness = snapshot?.freshness?.sections?.context;
|
||||
const identityFresh = snapshot?.context && !snapshot.context.error &&
|
||||
!freshness?.stale && !freshness?.degraded && !freshness?.revalidating;
|
||||
const login = identityFresh ? String(snapshot.context.user?.login || '').trim() : '';
|
||||
if (!login) return false;
|
||||
restoreIdentity(login);
|
||||
await Promise.all([
|
||||
flushIssue(),
|
||||
flushAuthored(),
|
||||
flushNotificationReads(),
|
||||
]);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports) module.exports = createReconnectOutboxes;
|
||||
@@ -32,6 +32,7 @@ const SHELL = [
|
||||
BASE + 'static/draft-capacity-dialog.js',
|
||||
BASE + 'static/outbox-coordinator.js',
|
||||
BASE + 'static/issue-outbox.js',
|
||||
BASE + 'static/reconnect-outboxes.js',
|
||||
BASE + 'static/authored-outbox.js',
|
||||
BASE + 'static/offline-issue-close.js',
|
||||
BASE + 'static/offline-issue-blocker.js',
|
||||
|
||||
Reference in new issue
Block a user