mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
Keep email list mounted between opens
This commit is contained in:
+26
-11
@@ -449,12 +449,27 @@ export function initEmailLibrary(config) {
|
|||||||
export function isOpen() { return state._libOpen; }
|
export function isOpen() { return state._libOpen; }
|
||||||
|
|
||||||
export function openEmailLibrary(opts = {}) {
|
export function openEmailLibrary(opts = {}) {
|
||||||
// Force-clean any stale state from previous attempts
|
|
||||||
const existing = document.getElementById('email-lib-modal');
|
const existing = document.getElementById('email-lib-modal');
|
||||||
if (existing) existing.remove();
|
if (existing) {
|
||||||
if (state._libEscHandler) {
|
existing.classList.remove('hidden');
|
||||||
document.removeEventListener('keydown', state._libEscHandler);
|
existing.style.display = 'block';
|
||||||
state._libEscHandler = null;
|
state._libOpen = true;
|
||||||
|
if (window.innerWidth <= 768) {
|
||||||
|
document.getElementById('sidebar')?.classList.add('hidden');
|
||||||
|
document.getElementById('sidebar-backdrop')?.classList.remove('visible');
|
||||||
|
}
|
||||||
|
document.body.classList.add('email-front');
|
||||||
|
if (Object.prototype.hasOwnProperty.call(opts, 'account_id')) {
|
||||||
|
state._libAccountId = opts.account_id || null;
|
||||||
|
_publishActiveAccount();
|
||||||
|
}
|
||||||
|
if (opts.folder) state._libFolder = opts.folder;
|
||||||
|
state._libPendingExpandUid = opts.uid || null;
|
||||||
|
_loadAccounts();
|
||||||
|
_loadFolders();
|
||||||
|
_loadEmailReminderBellVisibility();
|
||||||
|
_loadEmails({ preserveCurrent: true });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
state._libOpen = true;
|
state._libOpen = true;
|
||||||
// On mobile the sidebar overlays content — close it so the email view isn't
|
// On mobile the sidebar overlays content — close it so the email view isn't
|
||||||
@@ -958,6 +973,8 @@ export function openEmailLibrary(opts = {}) {
|
|||||||
|
|
||||||
// ESC to close + Arrow nav + Delete on the selected / currently-expanded email.
|
// ESC to close + Arrow nav + Delete on the selected / currently-expanded email.
|
||||||
state._libEscHandler = (e) => {
|
state._libEscHandler = (e) => {
|
||||||
|
const modal = document.getElementById('email-lib-modal');
|
||||||
|
if (!modal || modal.classList.contains('hidden')) return;
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
if (state._selectMode) {
|
if (state._selectMode) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -1044,12 +1061,8 @@ function _renderAccountsStrip() {
|
|||||||
|
|
||||||
export function closeEmailLibrary() {
|
export function closeEmailLibrary() {
|
||||||
const modal = document.getElementById('email-lib-modal');
|
const modal = document.getElementById('email-lib-modal');
|
||||||
if (modal) modal.remove();
|
if (modal) modal.classList.add('hidden');
|
||||||
_clearEmailDocumentSplit();
|
_clearEmailDocumentSplit();
|
||||||
if (state._libEscHandler) {
|
|
||||||
document.removeEventListener('keydown', state._libEscHandler);
|
|
||||||
state._libEscHandler = null;
|
|
||||||
}
|
|
||||||
state._libOpen = false;
|
state._libOpen = false;
|
||||||
// If the /email route collapsed the wide sidebar to make room for
|
// If the /email route collapsed the wide sidebar to make room for
|
||||||
// the fullscreen modal, re-expand it now that the modal is gone.
|
// the fullscreen modal, re-expand it now that the modal is gone.
|
||||||
@@ -1294,7 +1307,7 @@ async function _refreshUnreadBadge() {
|
|||||||
} catch (_) { _syncUnreadTabBadge(0); }
|
} catch (_) { _syncUnreadTabBadge(0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
async function _loadEmails({ force = false } = {}) {
|
async function _loadEmails({ force = false, preserveCurrent = false } = {}) {
|
||||||
const seq = ++_libLoadSeq;
|
const seq = ++_libLoadSeq;
|
||||||
state._libLoading = true;
|
state._libLoading = true;
|
||||||
const accountAtStart = state._libAccountId || '';
|
const accountAtStart = state._libAccountId || '';
|
||||||
@@ -1336,6 +1349,8 @@ async function _loadEmails({ force = false } = {}) {
|
|||||||
_renderGrid();
|
_renderGrid();
|
||||||
const stats = document.getElementById('email-lib-stats');
|
const stats = document.getElementById('email-lib-stats');
|
||||||
if (stats) stats.textContent = `${state._libTotal} emails`;
|
if (stats) stats.textContent = `${state._libTotal} emails`;
|
||||||
|
} else if (preserveCurrent && state._libEmails.length) {
|
||||||
|
sp = null;
|
||||||
} else {
|
} else {
|
||||||
grid.innerHTML = '';
|
grid.innerHTML = '';
|
||||||
sp = spinnerModule.createWhirlpool(28);
|
sp = spinnerModule.createWhirlpool(28);
|
||||||
|
|||||||
Reference in New Issue
Block a user