Settings: the saved-videos list folds

Settings → Offline cache lists every saved video; it now sits in a collapsible
'Saved videos' section showing the count and total size, closed by default,
remembering how it was left.
This commit is contained in:
Jonathan Sykes
2026-10-03 07:57:21 +08:00
parent 258aad83dd
commit 2c6f285cfe
2 changed files with 30 additions and 1 deletions

View File

@@ -9379,7 +9379,10 @@ async function renderSettings() {
<div class="set-actions">
<button id="clearCacheBtn" class="btn danger">Clear all cached videos</button>
</div>
<div id="cacheList" class="cache-list"></div>
<details id="cacheFold" class="cache-fold">
<summary><span>Saved videos</span><span id="cacheFoldCount" class="cache-fold-count"></span></summary>
<div id="cacheList" class="cache-list"></div>
</details>
</div>
<div class="set-group">
@@ -9644,6 +9647,13 @@ async function renderSettings() {
]);
});
// The saved-videos list folds; remember how the user left it.
{
const fold = $('cacheFold');
try { fold.open = localStorage.getItem('ytpCacheFoldOpen') === '1'; } catch { /* blocked */ }
fold.addEventListener('toggle', () => { try { localStorage.setItem('ytpCacheFoldOpen', fold.open ? '1' : '0'); } catch { /* blocked */ } });
}
// ---- Populate live cache stats ----
try {
const res = await API.cacheList();
@@ -9651,6 +9661,7 @@ async function renderSettings() {
const total = (res && res.total) || 0;
const items = (res && res.items) || [];
$('cacheTotal').textContent = `${fmtBytes(total)} · ${items.length} video${items.length === 1 ? '' : 's'}`;
$('cacheFoldCount').textContent = items.length ? `${items.length} · ${fmtBytes(total)}` : 'none';
const listEl = $('cacheList');
if (!items.length) {
listEl.innerHTML = '<div class="cache-empty">No videos saved offline yet.</div>';

View File

@@ -4333,3 +4333,21 @@ html.ios-nozoom, html.ios-nozoom body { touch-action: manipulation; }
.ch-pick-t { font: 500 12.5px var(--mono, ui-monospace, monospace); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ch-pick.on { background: color-mix(in srgb, var(--accent) 16%, var(--bg-2)); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.ch-pick.on .ch-pick-n, .ch-pick.on .ch-pick-t { color: var(--accent-bright); }
/* Settings → Offline cache: the saved-videos list folds */
.cache-fold { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-1); }
.cache-fold > summary {
list-style: none; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px;
cursor: pointer; font-weight: 600; color: var(--text); border-radius: 12px;
}
.cache-fold > summary::-webkit-details-marker { display: none; }
.cache-fold > summary::before {
content: ""; flex: none; width: 7px; height: 7px; margin-right: 2px;
border-right: 2px solid var(--text-dim); border-bottom: 2px solid var(--text-dim);
transform: rotate(-45deg); transition: transform .18s ease;
}
.cache-fold[open] > summary::before { transform: rotate(45deg); }
.cache-fold > summary:hover { background: var(--bg-2); }
.cache-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cache-fold-count { margin-left: auto; font-weight: 500; font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.cache-fold > .cache-list { margin: 0; padding: 4px 10px 10px; }