mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-30 00:22:10 -04:00
Email library: bulk 'Done' actually marks selected emails done
state._selectedUids holds whatever the server returns for em.uid (string or number); the bulk action looped Array.from(...) and did strict === against state._libEmails entries. When the types disagreed, the find() returned undefined, the in-memory is_answered flip never happened, and the post-loop _renderGrid() painted the cards back into their original not-done state — looking like 'mark done' did nothing even though the server-side call had succeeded. - Compare via String() on both sides so the in-memory state actually flips. - Surface HTTP failure from mark-answered/mark-read so the existing failedReadSync toast can fire if the calls don't go through.
This commit is contained in:
@@ -5025,13 +5025,18 @@ async function _bulkAction(action) {
|
|||||||
} else if (action === 'delete') {
|
} else if (action === 'delete') {
|
||||||
await fetch(`${API_BASE}/api/email/delete/${uid}?folder=${encodeURIComponent(state._libFolder)}${_acct()}`, { method: 'DELETE' });
|
await fetch(`${API_BASE}/api/email/delete/${uid}?folder=${encodeURIComponent(state._libFolder)}${_acct()}`, { method: 'DELETE' });
|
||||||
} else if (action === 'done') {
|
} else if (action === 'done') {
|
||||||
const em = state._libEmails.find(e => e.uid === uid);
|
// uid may come back from the Set as a string while em.uid is
|
||||||
|
// numeric (or vice versa) — coerce both sides so the in-memory
|
||||||
|
// state actually flips and the post-loop re-render shows the
|
||||||
|
// done checkmark.
|
||||||
|
const em = state._libEmails.find(e => String(e.uid) === String(uid));
|
||||||
if (em) {
|
if (em) {
|
||||||
em.is_answered = true;
|
em.is_answered = true;
|
||||||
em.is_read = true;
|
em.is_read = true;
|
||||||
}
|
}
|
||||||
await fetch(`${API_BASE}/api/email/mark-answered/${uid}?folder=${encodeURIComponent(state._libFolder)}${_acct()}`, { method: 'POST' });
|
const ansRes = await fetch(`${API_BASE}/api/email/mark-answered/${uid}?folder=${encodeURIComponent(state._libFolder)}${_acct()}`, { method: 'POST' });
|
||||||
await fetch(`${API_BASE}/api/email/mark-read/${uid}?folder=${encodeURIComponent(state._libFolder)}${_acct()}`, { method: 'POST' });
|
const readRes = await fetch(`${API_BASE}/api/email/mark-read/${uid}?folder=${encodeURIComponent(state._libFolder)}${_acct()}`, { method: 'POST' });
|
||||||
|
if (!ansRes.ok || !readRes.ok) throw new Error(`mark-done HTTP ${ansRes.status}/${readRes.status}`);
|
||||||
} else if (action === 'read' || action === 'unread') {
|
} else if (action === 'read' || action === 'unread') {
|
||||||
const endpoint = action === 'read' ? 'mark-read' : 'mark-unread';
|
const endpoint = action === 'read' ? 'mark-read' : 'mark-unread';
|
||||||
const res = await fetch(`${API_BASE}/api/email/${endpoint}/${uid}?folder=${encodeURIComponent(state._libFolder)}${_acct()}`, { method: 'POST' });
|
const res = await fetch(`${API_BASE}/api/email/${endpoint}/${uid}?folder=${encodeURIComponent(state._libFolder)}${_acct()}`, { method: 'POST' });
|
||||||
|
|||||||
Reference in New Issue
Block a user