mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
Fix library space toggles
This commit is contained in:
@@ -87,6 +87,7 @@ let _libraryArchivedView = false; // Documents tab showing archived docs?
|
|||||||
/** Collapse an expanded card */
|
/** Collapse an expanded card */
|
||||||
function _collapseExpandedCard(card) {
|
function _collapseExpandedCard(card) {
|
||||||
const grid = card.closest('.doclib-grid');
|
const grid = card.closest('.doclib-grid');
|
||||||
|
const instant = card?.dataset?.spaceToggle === '1';
|
||||||
card.classList.remove('doclib-card-expanded');
|
card.classList.remove('doclib-card-expanded');
|
||||||
// Release the height lock so grid returns to natural size
|
// Release the height lock so grid returns to natural size
|
||||||
if (grid) {
|
if (grid) {
|
||||||
@@ -97,7 +98,7 @@ let _libraryArchivedView = false; // Documents tab showing archived docs?
|
|||||||
if (reader) reader.remove();
|
if (reader) reader.remove();
|
||||||
|
|
||||||
// Fade siblings back in
|
// Fade siblings back in
|
||||||
if (grid) {
|
if (grid && !instant) {
|
||||||
const siblings = [...grid.querySelectorAll('.doclib-card')].filter(c => c !== card);
|
const siblings = [...grid.querySelectorAll('.doclib-card')].filter(c => c !== card);
|
||||||
siblings.forEach(s => { s.style.opacity = '0'; });
|
siblings.forEach(s => { s.style.opacity = '0'; });
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
@@ -812,6 +813,7 @@ let _libraryArchivedView = false; // Documents tab showing archived docs?
|
|||||||
|
|
||||||
async function libraryExpandCard(card, doc) {
|
async function libraryExpandCard(card, doc) {
|
||||||
const grid = card.closest('.doclib-grid');
|
const grid = card.closest('.doclib-grid');
|
||||||
|
const instant = card?.dataset?.spaceToggle === '1';
|
||||||
|
|
||||||
// Already expanded — collapse
|
// Already expanded — collapse
|
||||||
if (card.classList.contains('doclib-card-expanded')) {
|
if (card.classList.contains('doclib-card-expanded')) {
|
||||||
@@ -829,8 +831,10 @@ let _libraryArchivedView = false; // Documents tab showing archived docs?
|
|||||||
// Force explicit starting opacity so the first transition works
|
// Force explicit starting opacity so the first transition works
|
||||||
siblings.forEach(s => { s.style.opacity = '1'; });
|
siblings.forEach(s => { s.style.opacity = '1'; });
|
||||||
// Force reflow so the browser registers the starting value
|
// Force reflow so the browser registers the starting value
|
||||||
if (siblings.length) siblings[0].offsetHeight;
|
if (!instant) {
|
||||||
siblings.forEach(s => { s.style.transition = 'opacity 0.12s ease'; s.style.opacity = '0'; });
|
if (siblings.length) siblings[0].offsetHeight;
|
||||||
|
siblings.forEach(s => { s.style.transition = 'opacity 0.12s ease'; s.style.opacity = '0'; });
|
||||||
|
}
|
||||||
|
|
||||||
// Capture the full grid + toolbar height so the modal stays the same
|
// Capture the full grid + toolbar height so the modal stays the same
|
||||||
// size on desktop. On mobile the modal is full-height and we want the
|
// size on desktop. On mobile the modal is full-height and we want the
|
||||||
@@ -844,7 +848,7 @@ let _libraryArchivedView = false; // Documents tab showing archived docs?
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for fade-out, then expand
|
// Wait for fade-out, then expand
|
||||||
await new Promise(r => setTimeout(r, 120));
|
if (!instant) await new Promise(r => setTimeout(r, 120));
|
||||||
|
|
||||||
card.classList.add('doclib-card-expanded');
|
card.classList.add('doclib-card-expanded');
|
||||||
if (grid) grid.scrollTop = 0;
|
if (grid) grid.scrollTop = 0;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ function _targetEl(target) {
|
|||||||
const SPACE_CARD_SELECTOR = [
|
const SPACE_CARD_SELECTOR = [
|
||||||
'#email-lib-modal .doclib-card',
|
'#email-lib-modal .doclib-card',
|
||||||
'#doclib-modal .doclib-card',
|
'#doclib-modal .doclib-card',
|
||||||
|
'#doclib-modal .doclib-chat-row',
|
||||||
'#memory-modal .doclib-card',
|
'#memory-modal .doclib-card',
|
||||||
'#tasks-modal .task-card',
|
'#tasks-modal .task-card',
|
||||||
'#tasks-modal .task-log-row',
|
'#tasks-modal .task-log-row',
|
||||||
@@ -90,7 +91,11 @@ function _activateSpaceCard(card) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
card.dataset.spaceToggle = '1';
|
||||||
card.click();
|
card.click();
|
||||||
|
setTimeout(() => {
|
||||||
|
try { delete card.dataset.spaceToggle; } catch {}
|
||||||
|
}, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user