fix: wait for complete Agenda discovery (Closes #735)
This commit is contained in:
1 parent
4ac5a0f499
commit
64ff5127d8
6 files changed
+139
-6
No files matched your search
@@ -0,0 +1,33 @@
|
||||
(function (root, factory) {
|
||||
if (typeof module === 'object' && module.exports) module.exports = factory;
|
||||
else root.createAgendaSessionLauncher = factory;
|
||||
})(typeof self !== 'undefined' ? self : this, function createAgendaSessionLauncher(options) {
|
||||
let pending = null;
|
||||
|
||||
function open() {
|
||||
if (pending) return pending;
|
||||
options.selectAgenda();
|
||||
pending = Promise.resolve()
|
||||
.then(() => options.discover())
|
||||
.then(complete => {
|
||||
if (!options.isAgendaSelected()) return 'cancelled';
|
||||
if (complete === false || options.hasMore()) {
|
||||
options.announce('Agenda check paused. Retry to check older assigned deadlines.');
|
||||
return 'incomplete';
|
||||
}
|
||||
const opened = options.hasCheckpoint() ? options.resume() : options.start();
|
||||
if (!opened) options.announce('No deadlines are ready in Agenda.');
|
||||
return opened ? 'opened' : 'empty';
|
||||
})
|
||||
.catch(() => {
|
||||
if (options.isAgendaSelected()) {
|
||||
options.announce('Agenda check paused. Retry to check older assigned deadlines.');
|
||||
}
|
||||
return 'incomplete';
|
||||
})
|
||||
.finally(() => { pending = null; });
|
||||
return pending;
|
||||
}
|
||||
|
||||
return {open};
|
||||
});
|
||||
+16
-6
@@ -1210,11 +1210,18 @@
|
||||
qs('[data-work-filter="today"]').click();
|
||||
}
|
||||
|
||||
const agendaSessionLauncher = createAgendaSessionLauncher({
|
||||
selectAgenda: () => selectMobileQueue('agenda'),
|
||||
discover: completeAgendaIssues,
|
||||
isAgendaSelected: () => selectedWorkFilter === 'agenda',
|
||||
hasMore: () => Boolean(workPagination.issue?.has_more),
|
||||
hasCheckpoint: () => Boolean(agendaSessionCheckpoint.read()),
|
||||
resume: () => workSession.resume(),
|
||||
start: () => workSession.start(),
|
||||
announce: message => { qs('#my-work-action-status').textContent = message; },
|
||||
});
|
||||
function openAgendaSession() {
|
||||
selectMobileQueue('agenda');
|
||||
const opened = agendaSessionCheckpoint.read() ? workSession.resume() : workSession.start();
|
||||
if (!opened) qs('#my-work-action-status').textContent = 'No deadlines are ready in Agenda.';
|
||||
return opened ? 'opened' : 'empty';
|
||||
return agendaSessionLauncher.open();
|
||||
}
|
||||
|
||||
let todayReadinessTrigger = null;
|
||||
@@ -2340,17 +2347,20 @@
|
||||
}
|
||||
|
||||
async function completeAgendaIssues() {
|
||||
if (selectedWorkFilter !== 'agenda' || !workPagination.issue?.has_more || !lastContextSnapshot) return;
|
||||
if (selectedWorkFilter !== 'agenda') return false;
|
||||
if (!workPagination.issue?.has_more) return true;
|
||||
if (!lastContextSnapshot) return false;
|
||||
agendaChecking = true;
|
||||
qs('#my-work-action-status').textContent = 'Checking all assigned deadlines…';
|
||||
renderMyWork();
|
||||
const complete = await workPager.loadAll('issue', () => lastContextSnapshot?.issues || []);
|
||||
agendaChecking = false;
|
||||
if (selectedWorkFilter !== 'agenda') return;
|
||||
if (selectedWorkFilter !== 'agenda') return false;
|
||||
qs('#my-work-action-status').textContent = complete ?
|
||||
'All assigned deadlines checked.' :
|
||||
'Agenda check paused. Retry to check older assigned deadlines.';
|
||||
renderMyWork();
|
||||
return complete && !workPagination.issue?.has_more;
|
||||
}
|
||||
|
||||
function renderDrafts() {
|
||||
|
||||
@@ -1055,6 +1055,7 @@
|
||||
<script src="static/mobile-task-dock.js"></script>
|
||||
<script src="static/mobile-work-entry.js"></script>
|
||||
<script src="static/mobile-queue-launcher.js"></script>
|
||||
<script src="static/agenda-session-launcher.js"></script>
|
||||
<script src="static/mobile-launch.js"></script>
|
||||
<script src="static/install-app.js"></script>
|
||||
<script src="static/mobile-device-setup.js"></script>
|
||||
|
||||
@@ -74,6 +74,7 @@ const SHELL = [
|
||||
BASE + 'static/mobile-task-dock.js',
|
||||
BASE + 'static/mobile-work-entry.js',
|
||||
BASE + 'static/mobile-queue-launcher.js',
|
||||
BASE + 'static/agenda-session-launcher.js',
|
||||
BASE + 'static/mobile-launch.js',
|
||||
BASE + 'static/install-app.js',
|
||||
BASE + 'static/mobile-device-setup.js',
|
||||
|
||||
Reference in new issue
Block a user