feat: make Updates discovery atomic (Closes #753)
This commit is contained in:
1 parent
de6d6d0e61
commit
1f034a6f64
5 files changed
+110
-3
No files matched your search
@@ -1008,7 +1008,15 @@
|
||||
|
||||
const updateTriageLauncher = createUpdateTriageLauncher({
|
||||
selectUpdates: () => selectMobileQueue('update'),
|
||||
discover: () => notificationPager.loadAll(() => lastNotifications),
|
||||
discover: () => api('api/v1/notifications/snapshot'),
|
||||
applySnapshot: snapshot => {
|
||||
lastNotifications = snapshot.items || [];
|
||||
notificationPager.reset({page:1, total:snapshot.total || 0, has_more:false});
|
||||
if (lastContextSnapshot) {
|
||||
lastContextSnapshot.notifications = lastNotifications;
|
||||
paintMyWork(lastContextSnapshot);
|
||||
}
|
||||
},
|
||||
isUpdatesSelected: () => selectedWorkFilter === 'update',
|
||||
hasMore: () => Boolean(notificationPagination.has_more),
|
||||
hasCheckpoint: () => updateTriage.resumable(),
|
||||
|
||||
@@ -10,9 +10,14 @@
|
||||
options.announce('Checking all unread updates…');
|
||||
pending = Promise.resolve()
|
||||
.then(() => options.discover())
|
||||
.then(complete => {
|
||||
.then(discovery => {
|
||||
if (!options.isUpdatesSelected()) return 'cancelled';
|
||||
if (complete === false || options.hasMore()) {
|
||||
if (discovery === false || discovery?.complete === false) {
|
||||
options.announce('Updates check paused. Retry to check older unread updates.');
|
||||
return 'incomplete';
|
||||
}
|
||||
if (discovery?.complete) options.applySnapshot?.(discovery);
|
||||
if (options.hasMore()) {
|
||||
options.announce('Updates check paused. Retry to check older unread updates.');
|
||||
return 'incomplete';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user