feat: review mobile update triage outcomes (Closes #765)
This commit is contained in:
1 parent
e21cc58cca
commit
fd2f801f3e
5 files changed
+105
-10
No files matched your search
@@ -708,6 +708,9 @@ textarea { resize: vertical; min-height: 120px; }
|
||||
.mobile-queue-list [data-mobile-queue-count] { min-width:28px; padding:3px 8px; border-radius:999px; text-align:center; background:#1d426d; }
|
||||
.mobile-queue-list [data-mobile-queue="agenda"][data-deadlines="true"] { border-color:#f59e0b; background:#30240f; box-shadow:inset 3px 0 #f59e0b; }
|
||||
.mobile-queue-list [data-recommended="true"] { border-color:#60a5fa; box-shadow:0 0 0 2px #60a5fa; }
|
||||
.mobile-update-outcome { margin-top:12px; padding:12px; border:1px solid #31577f; border-radius:12px; background:#0b1b30; }
|
||||
.mobile-update-outcome p { margin:0 0 10px; }
|
||||
.mobile-update-outcome button { width:100%; min-height:44px; }
|
||||
.mobile-today-hud { position:fixed; left:8px; right:8px; bottom:calc(56px + env(safe-area-inset-bottom)); z-index:44; display:grid; grid-template-columns:minmax(0,1fr) minmax(112px,auto); grid-template-areas:"summary complete" "progress toggle"; gap:4px 8px; max-width:100%; padding:8px; border:1px solid #31577f; border-radius:12px 12px 0 0; background:rgba(16,38,65,.98); box-shadow:0 -8px 24px rgba(0,0,0,.28); }
|
||||
.mobile-today-summary { grid-area:summary; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:left; font-weight:700; }
|
||||
.mobile-today-hud [data-work-session-progress] { grid-area:progress; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
||||
|
||||
+21
-4
@@ -82,15 +82,28 @@
|
||||
|
||||
findWork: () => qs('#find-work').click(),
|
||||
});
|
||||
function showMobileQueueCompletion(completedName) {
|
||||
function showMobileQueueCompletion(completedName, cleared = true) {
|
||||
const next = mobileQueueLauncher.recommend();
|
||||
qs('#mobile-queue-heading').textContent = completedName + ' cleared';
|
||||
qs('#mobile-queue-heading').textContent = completedName + (cleared ? ' cleared' : '');
|
||||
document.querySelectorAll('[data-mobile-queue]').forEach(row => row.removeAttribute('data-recommended'));
|
||||
const row = qs('[data-mobile-queue="' + next.name + '"]');
|
||||
row.setAttribute('data-recommended', 'true');
|
||||
qs('#mobile-queue-sheet').showModal();
|
||||
row.focus();
|
||||
}
|
||||
let keptUpdateIdentities = [];
|
||||
function showUpdateTriageOutcome(outcome) {
|
||||
const box = qs('#mobile-update-outcome');
|
||||
const review = qs('#review-kept-updates');
|
||||
keptUpdateIdentities = outcome.keptIdentities;
|
||||
box.hidden = false;
|
||||
qs('#mobile-update-outcome-summary').textContent = outcome.reviewed + ' reviewed · ' + outcome.resolved +
|
||||
' marked read · ' + outcome.kept + ' kept unread';
|
||||
review.hidden = !outcome.kept;
|
||||
review.textContent = 'Review ' + outcome.kept + ' kept unread';
|
||||
showMobileQueueCompletion(outcome.kept ? 'Updates reviewed' : 'Updates', !outcome.kept);
|
||||
if (outcome.kept) review.focus();
|
||||
}
|
||||
const mobileTaskDock = createMobileTaskDock({
|
||||
nav: qs('#mobile-task-dock'),
|
||||
sessionHud: qs('[data-mobile-today-hud]'),
|
||||
@@ -1029,12 +1042,16 @@
|
||||
progress.hidden = false;
|
||||
progress.textContent = 'Update ' + state.index + ' of ' + state.total;
|
||||
},
|
||||
onFinish: () => {
|
||||
onFinish: outcome => {
|
||||
notificationReader.prefetch();
|
||||
qs('#update-triage-progress').hidden = true;
|
||||
showMobileQueueCompletion('Updates');
|
||||
showUpdateTriageOutcome(outcome);
|
||||
},
|
||||
});
|
||||
qs('#review-kept-updates').addEventListener('click', () => {
|
||||
qs('#mobile-queue-sheet').close();
|
||||
updateTriage.reviewKept(keptUpdateIdentities);
|
||||
});
|
||||
|
||||
const updateTriageLauncher = createUpdateTriageLauncher({
|
||||
selectUpdates: () => selectMobileQueue('update'),
|
||||
|
||||
@@ -993,6 +993,10 @@
|
||||
<dialog class="mobile-queue-sheet" id="mobile-queue-sheet" aria-labelledby="mobile-queue-heading">
|
||||
<section class="mobile-queue-panel">
|
||||
<header><h2 id="mobile-queue-heading">Work queues</h2><button id="close-mobile-queues" type="button">Close</button></header>
|
||||
<div id="mobile-update-outcome" class="mobile-update-outcome" role="status" aria-live="polite" hidden>
|
||||
<p id="mobile-update-outcome-summary"></p>
|
||||
<button id="review-kept-updates" type="button" hidden>Review kept unread</button>
|
||||
</div>
|
||||
<p class="small muted">Choose what to work through next.</p>
|
||||
<div class="mobile-queue-list">
|
||||
<button data-mobile-queue="today" type="button"><span><strong>Today</strong><small>Planned work</small></span><span data-mobile-queue-count="today">0</span></button>
|
||||
|
||||
@@ -7,18 +7,20 @@
|
||||
const login = () => String(options.getLogin() || '').trim();
|
||||
let state = null;
|
||||
let running = false;
|
||||
let lastOutcome = null;
|
||||
|
||||
function read() {
|
||||
const owner = login();
|
||||
if (!owner) return null;
|
||||
try {
|
||||
const value = JSON.parse(options.storage.getItem(key) || 'null');
|
||||
if (value?.version !== 1 || value.login !== owner || !Array.isArray(value.identities) ||
|
||||
if (![1, 2].includes(value?.version) || value.login !== owner || !Array.isArray(value.identities) ||
|
||||
!value.identities.length || typeof value.current !== 'string' || !Array.isArray(value.completed)) return null;
|
||||
const identities = value.identities.filter(value => typeof value === 'string' && value);
|
||||
const completed = value.completed.filter(value => identities.includes(value));
|
||||
const kept = Array.isArray(value.kept) ? value.kept.filter(value => identities.includes(value)) : [];
|
||||
if (!identities.length || !identities.includes(value.current)) return null;
|
||||
return { version:1, login:owner, identities, current:value.current, completed };
|
||||
return { version:2, login:owner, identities, current:value.current, completed, kept };
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
@@ -42,10 +44,15 @@
|
||||
}
|
||||
|
||||
function finish() {
|
||||
const unread = new Set((options.getItems() || []).map(identity).filter(Boolean));
|
||||
const keptIdentities = state ? state.kept.filter(id => unread.has(id)) : [];
|
||||
const reviewed = state ? state.completed.length : 0;
|
||||
const outcome = { reviewed, resolved:reviewed - keptIdentities.length, kept:keptIdentities.length, keptIdentities };
|
||||
lastOutcome = outcome;
|
||||
running = false;
|
||||
state = null;
|
||||
options.storage.removeItem(key);
|
||||
options.onFinish();
|
||||
options.onFinish(outcome);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -82,7 +89,7 @@
|
||||
start() {
|
||||
const identities = (options.getItems() || []).map(identity).filter(Boolean);
|
||||
if (!identities.length) return finish();
|
||||
state = { version:1, login:login(), identities, current:identities[0], completed:[] };
|
||||
state = { version:2, login:login(), identities, current:identities[0], completed:[], kept:[] };
|
||||
if (!state.login) return false;
|
||||
running = true;
|
||||
return openCurrent();
|
||||
@@ -99,7 +106,20 @@
|
||||
},
|
||||
completeAndNext: advance,
|
||||
acceptCompleted: () => advance(false),
|
||||
keepUnreadAndNext: advance,
|
||||
keepUnreadAndNext() {
|
||||
if (!running || !state) return false;
|
||||
if (!state.kept.includes(state.current)) state.kept.push(state.current);
|
||||
return advance();
|
||||
},
|
||||
reviewKept(identities = lastOutcome?.keptIdentities || []) {
|
||||
const unread = new Set((options.getItems() || []).map(identity).filter(Boolean));
|
||||
const kept = (identities || []).filter(id => unread.has(id));
|
||||
if (!kept.length) return false;
|
||||
state = { version:2, login:login(), identities:kept, current:kept[0], completed:[], kept:[] };
|
||||
if (!state.login) return false;
|
||||
running = true;
|
||||
return openCurrent();
|
||||
},
|
||||
next: nextAvailable,
|
||||
items: () => state ? available().slice() : [],
|
||||
end: finish,
|
||||
|
||||
Reference in new issue
Block a user