Fix sidebar async race and add watched tile overlays
@@ -55,6 +55,10 @@ const STATE = {
55
55
previewClosing: false, // guard to prevent double-close during animation
56
56
previewExpandState: null, // in-place expanded tile preview state
57
57
movePicker: null,
58
59
// Sidebar async loading guard to prevent stale updates on rapid selection changes.
60
sidebarLoadId: 0,
61
sidebarAbortController: null,
58
62
};
59
63
60
64
const SESSION_KEY = 'filemanager.session.v1';
@@ -1526,6 +1530,15 @@ function makeFileItem (item)
1526
1530
if (!item.isDir)
1527
1531
{
1528
1532
icon.dataset.previewPath = item.path;
1533
1534
const watchStatus = watchStatusForTile(item);
1535
if (watchStatus)
1536
{
1537
const overlay = document.createElement('div');
1538
overlay.className = `watched-overlay watched-overlay--${watchStatus}`;
1539
overlay.innerHTML = watchStatus === 'fully' ? watchedEyeFilledSvg() : watchedEyeOutlineSvg();
1540
icon.appendChild(overlay);
1541
}
1529
1542
} else
1530
1543
{
1531
1544
icon.dataset.folderPath = item.path;
@@ -1648,6 +1661,34 @@ function selectItem (el, item)
1648
1661
openSidebar(item);
1649
1662
}
1650
1663
1664
function isAbortError (err)
1665
{
1666
if (!err) return false;
1667
return err.name === 'AbortError' || /abort/i.test(String(err.message || ''));
1668
}
1669
1670
function beginSidebarLoad ()
1671
{
1672
if (STATE.sidebarAbortController && typeof STATE.sidebarAbortController.abort === 'function')
1673
{
1674
try { STATE.sidebarAbortController.abort(); } catch { /* ignore */ }
1675
}
1676
1677
STATE.sidebarLoadId += 1;
1678
STATE.sidebarAbortController = null;
1679
1680
return {
1681
id: STATE.sidebarLoadId,
1682
};
1683
}
1684
1685
function isSidebarLoadStale (item, sidebarLoadId)
1686
{
1687
if (sidebarLoadId !== STATE.sidebarLoadId) return true;
1688
if (!STATE.selectedItem) return true;
1689
return STATE.selectedItem !== item && STATE.selectedItem.path !== item.path;
1690
}
1691
1651
1692
// ───────────────────────────────────────────────────────────────────────────
1652
1693
// SIDEBAR
1653
1694
// ───────────────────────────────────────────────────────────────────────────
@@ -1749,6 +1790,8 @@ async function navigateToDuplicate (dup)
1749
1790
1750
1791
async function openSidebar (item)
1751
1792
{
1793
const sidebarLoad = beginSidebarLoad();
1794
1752
1795
const sidebar = document.getElementById('sidebar');
1753
1796
sidebar.classList.remove('hidden');
1754
1797
document.getElementById('app').classList.add('sidebar-open');
@@ -1775,7 +1818,13 @@ async function openSidebar (item)
1775
1818
1776
1819
if (!item.isDir)
1777
1820
{
1778
const meta = await api('GET', `/files/meta?file=${encodeURIComponent(item.path)}`);
1821
const meta = await api('GET', `/files/meta?file=${encodeURIComponent(item.path)}`).catch((err) =>
1822
{
1823
if (isAbortError(err)) return null;
1824
throw err;
1825
});
1826
if (isSidebarLoadStale(item, sidebarLoad.id)) return;
1827
1779
1828
if (meta)
1780
1829
{
1781
1830
const watchedBy = VIDEO_EXTS.has(extOf(item.name))
@@ -1799,11 +1848,14 @@ async function openSidebar (item)
1799
1848
api('GET', `/files/duplicates?file=${encodeURIComponent(item.path)}`)
1800
1849
.then((data) =>
1801
1850
{
1851
if (isSidebarLoadStale(item, sidebarLoad.id)) return;
1802
1852
if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;
1803
1853
renderSidebarDuplicates(item, data ? data.duplicates : []);
1804
1854
})
1805
.catch(() =>
1855
.catch((err) =>
1806
1856
{
1857
if (isAbortError(err)) return;
1858
if (isSidebarLoadStale(item, sidebarLoad.id)) return;
1807
1859
if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;
1808
1860
renderSidebarDuplicates(item, []);
1809
1861
});
@@ -1835,7 +1887,13 @@ async function openSidebar (item)
1835
1887
<dt>Original name</dt><dd>${item._root.originalName || basenameOfPath(item.path)}</dd>
1836
1888
`;
1837
1889
1838
const space = await api('GET', `/files/space?dir=${encodeURIComponent(item.path)}`).catch(() => null);
1890
const space = await api('GET', `/files/space?dir=${encodeURIComponent(item.path)}`).catch((err) =>
1891
{
1892
if (isAbortError(err)) return null;
1893
return null;
1894
});
1895
if (isSidebarLoadStale(item, sidebarLoad.id)) return;
1896
1839
1897
if (space)
1840
1898
{
1841
1899
const used = formatBytes(space.usedBytes);
@@ -1857,6 +1915,7 @@ async function openSidebar (item)
1857
1915
} else
1858
1916
{
1859
1917
const accessUsers = await fetchRootAccessList(item.path);
1918
if (isSidebarLoadStale(item, sidebarLoad.id)) return;
1860
1919
if (accessUsers)
1861
1920
{
1862
1921
dl.innerHTML += `
@@ -1962,6 +2021,8 @@ async function openSidebar (item)
1962
2021
1963
2022
function openFolderSidebar ()
1964
2023
{
2024
beginSidebarLoad();
2025
1965
2026
const sidebar = document.getElementById('sidebar');
1966
2027
sidebar.classList.remove('hidden');
1967
2028
document.getElementById('app').classList.add('sidebar-open');
@@ -2023,6 +2084,7 @@ function openFolderSidebar ()
2023
2084
function closeSidebar ()
2024
2085
{
2025
2086
if (typeof document === 'undefined' || typeof document.querySelectorAll !== 'function') return;
2087
beginSidebarLoad();
2026
2088
document.querySelectorAll('.file-item.selected').forEach(e => e.classList.remove('selected'));
2027
2089
STATE.selectedItem = null;
2028
2090
@@ -2057,7 +2119,11 @@ function basenameOfPath (p)
2057
2119
async function fetchRootAccessList (rootPath)
2058
2120
{
2059
2121
if (!rootPath) return null;
2060
const data = await api('GET', `/files/root-access?rootPath=${encodeURIComponent(rootPath)}`).catch(() => null);
2122
const data = await api('GET', `/files/root-access?rootPath=${encodeURIComponent(rootPath)}`).catch((err) =>
2123
{
2124
if (isAbortError(err)) return null;
2125
return null;
2126
});
2061
2127
if (!data || !Array.isArray(data.users)) return null;
2062
2128
return data.users;
2063
2129
}
@@ -2945,13 +3011,18 @@ async function renderStreamedVideoPreview (item, targetEl)
2945
3011
{
2946
3012
player.volume(Math.max(0, Math.min(1, volume)));
2947
3013
}
2948
const settings = this.textTrackSettings;
2949
settings.setValues({
2950
"backgroundColor": "#000",
2951
"backgroundOpacity": "0",
2952
"edgeStyle": "uniform",
2953
});
2954
settings.updateDisplay();
3014
3015
const settings = player && player.textTrackSettings;
3016
if (settings && typeof settings.setValues === 'function' && typeof settings.updateDisplay === 'function')
3017
{
3018
settings.setValues({
3019
backgroundColor: '#000',
3020
backgroundOpacity: '0',
3021
edgeStyle: 'uniform',
3022
});
3023
settings.updateDisplay();
3024
}
3025
2955
3026
trackPrefs.applySavedTracks();
2956
3027
});
2957
3028
@@ -4104,6 +4175,31 @@ function iconFile (name, size = 52)
4104
4175
</svg>`;
4105
4176
}
4106
4177
4178
function watchStatusForTile (item)
4179
{
4180
if (!item || item.isDir) return null;
4181
if (!VIDEO_EXTS.has(extOf(item.name || ''))) return null;
4182
4183
const currentUser = String(STATE.username || '').trim();
4184
if (!currentUser) return null;
4185
4186
const watchedBy = item.watchedBy && typeof item.watchedBy === 'object' ? item.watchedBy : {};
4187
const statusRaw = watchedBy[currentUser];
4188
const status = String(statusRaw || '').toLowerCase();
4189
if (status === 'fully' || status === 'partway') return status;
4190
return null;
4191
}
4192
4193
function watchedEyeFilledSvg ()
4194
{
4195
return `<svg class="watched-overlay-svg" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path fill="#ffffff" d="M651.669528 512c0-14.5903-2.084475-28.290323-6.251378-41.395806-11.019984 24.423249-35.143405 41.395806-63.733557 41.395806l-7.440459-0.593518-5.957689 0.593518c-30.973432 0-56.285934-25.607214-56.285934-56.882522l0.297782-5.952572-0.297782-7.447623c0-28.290323 16.97665-52.709479 41.097-63.727417-13.104459-4.172019-26.802436-6.252401-41.097-6.252401-77.132728 0-139.67311 62.834071-139.67311 140.263557 0 77.428464 62.540382 139.971915 139.67311 139.971915S651.669528 589.428464 651.669528 512L651.669528 512zM958.70846 512c0 0-153.36904-297.80564-448.198905-297.80564-293.63669 0-445.219037 297.80564-445.219037 297.80564s164.385954 297.804616 447.306582 297.804616C805.038568 809.80564 958.70846 512 958.70846 512L958.70846 512zM304.725748 512c0-114.954125 92.619444-208.164017 207.27374-208.164017 114.657366 0 207.27067 93.209892 207.27067 208.164017 0 114.953102-92.613304 208.167087-207.27067 208.167087C397.345192 720.167087 304.725748 626.953102 304.725748 512L304.725748 512zM304.725748 512"/></svg>`;
4196
}
4197
4198
function watchedEyeOutlineSvg ()
4199
{
4200
return `<svg class="watched-overlay-svg" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path fill="none" stroke="#ffffff" stroke-width="17.8" stroke-dasharray="none" d="M651.669528 512c0-14.5903-2.084475-28.290323-6.251378-41.395806-11.019984 24.423249-35.143405 41.395806-63.733557 41.395806l-7.440459-0.593518-5.957689 0.593518c-30.973432 0-56.285934-25.607214-56.285934-56.882522l0.297782-5.952572-0.297782-7.447623c0-28.290323 16.97665-52.709479 41.097-63.727417-13.104459-4.172019-26.802436-6.252401-41.097-6.252401-77.132728 0-139.67311 62.834071-139.67311 140.263557 0 77.428464 62.540382 139.971915 139.67311 139.971915S651.669528 589.428464 651.669528 512L651.669528 512zM958.70846 512c0 0-153.36904-297.80564-448.198905-297.80564-293.63669 0-445.219037 297.80564-445.219037 297.80564s164.385954 297.804616 447.306582 297.804616C805.038568 809.80564 958.70846 512 958.70846 512L958.70846 512zM304.725748 512c0-114.954125 92.619444-208.164017 207.27374-208.164017 114.657366 0 207.27067 93.209892 207.27067 208.164017 0 114.953102-92.613304 208.167087-207.27067 208.167087C397.345192 720.167087 304.725748 626.953102 304.725748 512L304.725748 512"/></svg>`;
4201
}
4202
4107
4203
// ───────────────────────────────────────────────────────────────────────────
4108
4204
// EVENT WIRING
4109
4205
// ───────────────────────────────────────────────────────────────────────────
@@ -55,6 +55,10 @@ const STATE = {55
previewClosing: false, // guard to prevent double-close during animation55
previewClosing: false, // guard to prevent double-close during animation56
previewExpandState: null, // in-place expanded tile preview state56
previewExpandState: null, // in-place expanded tile preview state57
movePicker: null,57
movePicker: null,58
59
// Sidebar async loading guard to prevent stale updates on rapid selection changes.60
sidebarLoadId: 0,61
sidebarAbortController: null,58
};62
};59
63
60
const SESSION_KEY = 'filemanager.session.v1';64
const SESSION_KEY = 'filemanager.session.v1';@@ -1526,6 +1530,15 @@ function makeFileItem (item)1526
if (!item.isDir)1530
if (!item.isDir)1527
{1531
{1528
icon.dataset.previewPath = item.path;1532
icon.dataset.previewPath = item.path;1533
1534
const watchStatus = watchStatusForTile(item);1535
if (watchStatus)1536
{1537
const overlay = document.createElement('div');1538
overlay.className = `watched-overlay watched-overlay--${watchStatus}`;1539
overlay.innerHTML = watchStatus === 'fully' ? watchedEyeFilledSvg() : watchedEyeOutlineSvg();1540
icon.appendChild(overlay);1541
}1529
} else1542
} else1530
{1543
{1531
icon.dataset.folderPath = item.path;1544
icon.dataset.folderPath = item.path;@@ -1648,6 +1661,34 @@ function selectItem (el, item)1648
openSidebar(item);1661
openSidebar(item);1649
}1662
}1650
1663
1664
function isAbortError (err)1665
{1666
if (!err) return false;1667
return err.name === 'AbortError' || /abort/i.test(String(err.message || ''));1668
}1669
1670
function beginSidebarLoad ()1671
{1672
if (STATE.sidebarAbortController && typeof STATE.sidebarAbortController.abort === 'function')1673
{1674
try { STATE.sidebarAbortController.abort(); } catch { /* ignore */ }1675
}1676
1677
STATE.sidebarLoadId += 1;1678
STATE.sidebarAbortController = null;1679
1680
return {1681
id: STATE.sidebarLoadId,1682
};1683
}1684
1685
function isSidebarLoadStale (item, sidebarLoadId)1686
{1687
if (sidebarLoadId !== STATE.sidebarLoadId) return true;1688
if (!STATE.selectedItem) return true;1689
return STATE.selectedItem !== item && STATE.selectedItem.path !== item.path;1690
}1691
1651
// ───────────────────────────────────────────────────────────────────────────1692
// ───────────────────────────────────────────────────────────────────────────1652
// SIDEBAR1693
// SIDEBAR1653
// ───────────────────────────────────────────────────────────────────────────1694
// ───────────────────────────────────────────────────────────────────────────@@ -1749,6 +1790,8 @@ async function navigateToDuplicate (dup)1749
1790
1750
async function openSidebar (item)1791
async function openSidebar (item)1751
{1792
{1793
const sidebarLoad = beginSidebarLoad();1794
1752
const sidebar = document.getElementById('sidebar');1795
const sidebar = document.getElementById('sidebar');1753
sidebar.classList.remove('hidden');1796
sidebar.classList.remove('hidden');1754
document.getElementById('app').classList.add('sidebar-open');1797
document.getElementById('app').classList.add('sidebar-open');@@ -1775,7 +1818,13 @@ async function openSidebar (item)1775
1818
1776
if (!item.isDir)1819
if (!item.isDir)1777
{1820
{1778
const meta = await api('GET', `/files/meta?file=${encodeURIComponent(item.path)}`);1821
const meta = await api('GET', `/files/meta?file=${encodeURIComponent(item.path)}`).catch((err) =>1822
{1823
if (isAbortError(err)) return null;1824
throw err;1825
});1826
if (isSidebarLoadStale(item, sidebarLoad.id)) return;1827
1779
if (meta)1828
if (meta)1780
{1829
{1781
const watchedBy = VIDEO_EXTS.has(extOf(item.name))1830
const watchedBy = VIDEO_EXTS.has(extOf(item.name))@@ -1799,11 +1848,14 @@ async function openSidebar (item)1799
api('GET', `/files/duplicates?file=${encodeURIComponent(item.path)}`)1848
api('GET', `/files/duplicates?file=${encodeURIComponent(item.path)}`)1800
.then((data) =>1849
.then((data) =>1801
{1850
{1851
if (isSidebarLoadStale(item, sidebarLoad.id)) return;1802
if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;1852
if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;1803
renderSidebarDuplicates(item, data ? data.duplicates : []);1853
renderSidebarDuplicates(item, data ? data.duplicates : []);1804
})1854
})1805
.catch(() =>1855
.catch((err) =>1806
{1856
{1857
if (isAbortError(err)) return;1858
if (isSidebarLoadStale(item, sidebarLoad.id)) return;1807
if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;1859
if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;1808
renderSidebarDuplicates(item, []);1860
renderSidebarDuplicates(item, []);1809
});1861
});@@ -1835,7 +1887,13 @@ async function openSidebar (item)1835
<dt>Original name</dt><dd>${item._root.originalName || basenameOfPath(item.path)}</dd>1887
<dt>Original name</dt><dd>${item._root.originalName || basenameOfPath(item.path)}</dd>1836
`;1888
`;1837
1889
1838
const space = await api('GET', `/files/space?dir=${encodeURIComponent(item.path)}`).catch(() => null);1890
const space = await api('GET', `/files/space?dir=${encodeURIComponent(item.path)}`).catch((err) =>1891
{1892
if (isAbortError(err)) return null;1893
return null;1894
});1895
if (isSidebarLoadStale(item, sidebarLoad.id)) return;1896
1839
if (space)1897
if (space)1840
{1898
{1841
const used = formatBytes(space.usedBytes);1899
const used = formatBytes(space.usedBytes);@@ -1857,6 +1915,7 @@ async function openSidebar (item)1857
} else1915
} else1858
{1916
{1859
const accessUsers = await fetchRootAccessList(item.path);1917
const accessUsers = await fetchRootAccessList(item.path);1918
if (isSidebarLoadStale(item, sidebarLoad.id)) return;1860
if (accessUsers)1919
if (accessUsers)1861
{1920
{1862
dl.innerHTML += `1921
dl.innerHTML += `@@ -1962,6 +2021,8 @@ async function openSidebar (item)1962
2021
1963
function openFolderSidebar ()2022
function openFolderSidebar ()1964
{2023
{2024
beginSidebarLoad();2025
1965
const sidebar = document.getElementById('sidebar');2026
const sidebar = document.getElementById('sidebar');1966
sidebar.classList.remove('hidden');2027
sidebar.classList.remove('hidden');1967
document.getElementById('app').classList.add('sidebar-open');2028
document.getElementById('app').classList.add('sidebar-open');@@ -2023,6 +2084,7 @@ function openFolderSidebar ()2023
function closeSidebar ()2084
function closeSidebar ()2024
{2085
{2025
if (typeof document === 'undefined' || typeof document.querySelectorAll !== 'function') return;2086
if (typeof document === 'undefined' || typeof document.querySelectorAll !== 'function') return;2087
beginSidebarLoad();2026
document.querySelectorAll('.file-item.selected').forEach(e => e.classList.remove('selected'));2088
document.querySelectorAll('.file-item.selected').forEach(e => e.classList.remove('selected'));2027
STATE.selectedItem = null;2089
STATE.selectedItem = null;2028
2090
@@ -2057,7 +2119,11 @@ function basenameOfPath (p)2057
async function fetchRootAccessList (rootPath)2119
async function fetchRootAccessList (rootPath)2058
{2120
{2059
if (!rootPath) return null;2121
if (!rootPath) return null;2060
const data = await api('GET', `/files/root-access?rootPath=${encodeURIComponent(rootPath)}`).catch(() => null);2122
const data = await api('GET', `/files/root-access?rootPath=${encodeURIComponent(rootPath)}`).catch((err) =>2123
{2124
if (isAbortError(err)) return null;2125
return null;2126
});2061
if (!data || !Array.isArray(data.users)) return null;2127
if (!data || !Array.isArray(data.users)) return null;2062
return data.users;2128
return data.users;2063
}2129
}@@ -2945,13 +3011,18 @@ async function renderStreamedVideoPreview (item, targetEl)2945
{3011
{2946
player.volume(Math.max(0, Math.min(1, volume)));3012
player.volume(Math.max(0, Math.min(1, volume)));2947
}3013
}2948
const settings = this.textTrackSettings;3014
2949
settings.setValues({3015
const settings = player && player.textTrackSettings;2950
"backgroundColor": "#000",3016
if (settings && typeof settings.setValues === 'function' && typeof settings.updateDisplay === 'function')2951
"backgroundOpacity": "0",3017
{2952
"edgeStyle": "uniform",3018
settings.setValues({2953
});3019
backgroundColor: '#000',2954
settings.updateDisplay();3020
backgroundOpacity: '0',3021
edgeStyle: 'uniform',3022
});3023
settings.updateDisplay();3024
}3025
2955
trackPrefs.applySavedTracks();3026
trackPrefs.applySavedTracks();2956
});3027
});2957
3028
@@ -4104,6 +4175,31 @@ function iconFile (name, size = 52)4104
</svg>`;4175
</svg>`;4105
}4176
}4106
4177
4178
function watchStatusForTile (item)4179
{4180
if (!item || item.isDir) return null;4181
if (!VIDEO_EXTS.has(extOf(item.name || ''))) return null;4182
4183
const currentUser = String(STATE.username || '').trim();4184
if (!currentUser) return null;4185
4186
const watchedBy = item.watchedBy && typeof item.watchedBy === 'object' ? item.watchedBy : {};4187
const statusRaw = watchedBy[currentUser];4188
const status = String(statusRaw || '').toLowerCase();4189
if (status === 'fully' || status === 'partway') return status;4190
return null;4191
}4192
4193
function watchedEyeFilledSvg ()4194
{4195
return `<svg class="watched-overlay-svg" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path fill="#ffffff" d="M651.669528 512c0-14.5903-2.084475-28.290323-6.251378-41.395806-11.019984 24.423249-35.143405 41.395806-63.733557 41.395806l-7.440459-0.593518-5.957689 0.593518c-30.973432 0-56.285934-25.607214-56.285934-56.882522l0.297782-5.952572-0.297782-7.447623c0-28.290323 16.97665-52.709479 41.097-63.727417-13.104459-4.172019-26.802436-6.252401-41.097-6.252401-77.132728 0-139.67311 62.834071-139.67311 140.263557 0 77.428464 62.540382 139.971915 139.67311 139.971915S651.669528 589.428464 651.669528 512L651.669528 512zM958.70846 512c0 0-153.36904-297.80564-448.198905-297.80564-293.63669 0-445.219037 297.80564-445.219037 297.80564s164.385954 297.804616 447.306582 297.804616C805.038568 809.80564 958.70846 512 958.70846 512L958.70846 512zM304.725748 512c0-114.954125 92.619444-208.164017 207.27374-208.164017 114.657366 0 207.27067 93.209892 207.27067 208.164017 0 114.953102-92.613304 208.167087-207.27067 208.167087C397.345192 720.167087 304.725748 626.953102 304.725748 512L304.725748 512zM304.725748 512"/></svg>`;4196
}4197
4198
function watchedEyeOutlineSvg ()4199
{4200
return `<svg class="watched-overlay-svg" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path fill="none" stroke="#ffffff" stroke-width="17.8" stroke-dasharray="none" d="M651.669528 512c0-14.5903-2.084475-28.290323-6.251378-41.395806-11.019984 24.423249-35.143405 41.395806-63.733557 41.395806l-7.440459-0.593518-5.957689 0.593518c-30.973432 0-56.285934-25.607214-56.285934-56.882522l0.297782-5.952572-0.297782-7.447623c0-28.290323 16.97665-52.709479 41.097-63.727417-13.104459-4.172019-26.802436-6.252401-41.097-6.252401-77.132728 0-139.67311 62.834071-139.67311 140.263557 0 77.428464 62.540382 139.971915 139.67311 139.971915S651.669528 589.428464 651.669528 512L651.669528 512zM958.70846 512c0 0-153.36904-297.80564-448.198905-297.80564-293.63669 0-445.219037 297.80564-445.219037 297.80564s164.385954 297.804616 447.306582 297.804616C805.038568 809.80564 958.70846 512 958.70846 512L958.70846 512zM304.725748 512c0-114.954125 92.619444-208.164017 207.27374-208.164017 114.657366 0 207.27067 93.209892 207.27067 208.164017 0 114.953102-92.613304 208.167087-207.27067 208.167087C397.345192 720.167087 304.725748 626.953102 304.725748 512L304.725748 512"/></svg>`;4201
}4202
4107
// ───────────────────────────────────────────────────────────────────────────4203
// ───────────────────────────────────────────────────────────────────────────4108
// EVENT WIRING4204
// EVENT WIRING4109
// ───────────────────────────────────────────────────────────────────────────4205
// ───────────────────────────────────────────────────────────────────────────@@ -341,6 +341,26 @@ button.danger:hover {
341
341
height: 100%;
342
342
}
343
343
344
.file-item .icon .watched-overlay {
345
position: absolute;
346
left: 50%;
347
top: 50%;
348
width: 28px;
349
height: 28px;
350
transform: translate(-50%, -50%);
351
display: flex;
352
align-items: center;
353
justify-content: center;
354
pointer-events: none;
355
border-radius: 50%;
356
background: rgba(15, 17, 23, 0.45);
357
}
358
359
.file-item .icon .watched-overlay-svg {
360
width: 100%;
361
height: 100%;
362
}
363
344
364
.file-item .name {
345
365
font-size: 0.8rem;
346
366
word-break: break-all;
@@ -341,6 +341,26 @@ button.danger:hover {341
height: 100%;
341
height: 100%;
342
}
342
}
343
343
344
.file-item .icon .watched-overlay {
345
position: absolute;
346
left: 50%;
347
top: 50%;
348
width: 28px;
349
height: 28px;
350
transform: translate(-50%, -50%);
351
display: flex;
352
align-items: center;
353
justify-content: center;
354
pointer-events: none;
355
border-radius: 50%;
356
background: rgba(15, 17, 23, 0.45);
357
}
358
359
.file-item .icon .watched-overlay-svg {
360
width: 100%;
361
height: 100%;
362
}
363
344
.file-item .name {
364
.file-item .name {
345
font-size: 0.8rem;
365
font-size: 0.8rem;
346
word-break: break-all;
366
word-break: break-all;
@@ -28,6 +28,7 @@ describe('page load smoke test', () =>
28
28
let adminConfigFixture;
29
29
let downloadFixture;
30
30
let videoStreamFixture;
31
let metaDelayMsFixture;
31
32
let releasedVideoStreamSessions;
32
33
let setupNeededFixture;
33
34
const openDoms = [];
@@ -57,6 +58,7 @@ describe('page load smoke test', () =>
57
58
adminConfigFixture = { port: 3000, paths: ['/data'], effectivePaths: ['/data'] };
58
59
downloadFixture = {};
59
60
videoStreamFixture = {};
61
metaDelayMsFixture = {};
60
62
releasedVideoStreamSessions = [];
61
63
setupNeededFixture = false;
62
64
});
@@ -115,14 +117,26 @@ describe('page load smoke test', () =>
115
117
{
116
118
return res.status(404).json({ error: 'File not found.' });
117
119
}
118
res.json({
119
name: item.name,
120
size: item.size || 0,
121
mtime: new Date(item.mtime || Date.now()).toISOString(),
122
uploader: '',
123
downloaders: [],
124
watchedBy: {},
125
});
120
const sendMeta = () =>
121
{
122
res.json({
123
name: item.name,
124
size: item.size || 0,
125
mtime: new Date(item.mtime || Date.now()).toISOString(),
126
uploader: '',
127
downloaders: [],
128
watchedBy: item.watchedBy || {},
129
});
130
};
131
132
const delayMs = Number(metaDelayMsFixture[file] || 0);
133
if (delayMs > 0)
134
{
135
setTimeout(sendMeta, delayMs);
136
return;
137
}
138
139
sendMeta();
126
140
});
127
141
app.post('/api/files/video-stream', (req, res) =>
128
142
{
@@ -687,6 +701,90 @@ describe('page load smoke test', () =>
687
701
dom.window.close();
688
702
});
689
703
704
test('rapid file reselection does not duplicate sidebar action buttons after delayed metadata', async () =>
705
{
706
listFixture = {
707
'/data': [
708
{
709
name: 'first.txt',
710
path: '/data/first.txt',
711
isDir: false,
712
size: 10,
713
mtime: Date.now(),
714
},
715
{
716
name: 'second.txt',
717
path: '/data/second.txt',
718
isDir: false,
719
size: 20,
720
mtime: Date.now(),
721
},
722
],
723
};
724
metaDelayMsFixture['/data/first.txt'] = 120;
725
726
const { dom, runtimeErrors } = await bootClient();
727
expect(runtimeErrors).toEqual([]);
728
729
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/first.txt"]'));
730
const firstTile = dom.window.document.querySelector('.file-item[data-path="/data/first.txt"]');
731
const secondTile = dom.window.document.querySelector('.file-item[data-path="/data/second.txt"]');
732
expect(firstTile).toBeTruthy();
733
expect(secondTile).toBeTruthy();
734
735
firstTile.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
736
await new Promise(resolve => dom.window.setTimeout(resolve, 10));
737
secondTile.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
738
739
await new Promise(resolve => dom.window.setTimeout(resolve, 220));
740
741
const actionButtons = Array.from(dom.window.document.querySelectorAll('#sidebar-actions button')).map(b => b.textContent);
742
expect(actionButtons).toEqual(['View / Download', 'Share']);
743
744
dom.window.close();
745
});
746
747
test('video tiles show centred watched overlays for fully and partway statuses', async () =>
748
{
749
listFixture = {
750
'/data': [
751
{
752
name: 'watched-full.mkv',
753
path: '/data/watched-full.mkv',
754
isDir: false,
755
size: 100,
756
mtime: Date.now(),
757
watchedBy: { tester: 'fully' },
758
},
759
{
760
name: 'watched-part.mkv',
761
path: '/data/watched-part.mkv',
762
isDir: false,
763
size: 100,
764
mtime: Date.now(),
765
watchedBy: { tester: 'partway' },
766
},
767
],
768
};
769
770
const { dom, runtimeErrors } = await bootClient();
771
expect(runtimeErrors).toEqual([]);
772
773
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay--fully'));
774
775
const fullOverlayPath = dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay--fully path');
776
const partOverlayPath = dom.window.document.querySelector('.file-item[data-path="/data/watched-part.mkv"] .watched-overlay--partway path');
777
778
expect(fullOverlayPath).toBeTruthy();
779
expect(fullOverlayPath.getAttribute('fill')).toBe('#ffffff');
780
781
expect(partOverlayPath).toBeTruthy();
782
expect(partOverlayPath.getAttribute('fill')).toBe('none');
783
expect(partOverlayPath.getAttribute('stroke')).toBe('#ffffff');
784
785
dom.window.close();
786
});
787
690
788
test('admin user modal locks write checkbox while read is unchecked', async () =>
691
789
{
692
790
meFixture = { username: 'admin', isAdmin: true, permissions: {} };
@@ -28,6 +28,7 @@ describe('page load smoke test', () =>28
let adminConfigFixture;
28
let adminConfigFixture;
29
let downloadFixture;
29
let downloadFixture;
30
let videoStreamFixture;
30
let videoStreamFixture;
31
let metaDelayMsFixture;
31
let releasedVideoStreamSessions;
32
let releasedVideoStreamSessions;
32
let setupNeededFixture;
33
let setupNeededFixture;
33
const openDoms = [];
34
const openDoms = [];
@@ -57,6 +58,7 @@ describe('page load smoke test', () =>57
adminConfigFixture = { port: 3000, paths: ['/data'], effectivePaths: ['/data'] };
58
adminConfigFixture = { port: 3000, paths: ['/data'], effectivePaths: ['/data'] };
58
downloadFixture = {};
59
downloadFixture = {};
59
videoStreamFixture = {};
60
videoStreamFixture = {};
61
metaDelayMsFixture = {};
60
releasedVideoStreamSessions = [];
62
releasedVideoStreamSessions = [];
61
setupNeededFixture = false;
63
setupNeededFixture = false;
62
});
64
});
@@ -115,14 +117,26 @@ describe('page load smoke test', () =>115
{
117
{
116
return res.status(404).json({ error: 'File not found.' });
118
return res.status(404).json({ error: 'File not found.' });
117
}
119
}
118
res.json({
120
const sendMeta = () =>
119
name: item.name,
121
{
120
size: item.size || 0,
122
res.json({
121
mtime: new Date(item.mtime || Date.now()).toISOString(),
123
name: item.name,
122
uploader: '',
124
size: item.size || 0,
123
downloaders: [],
125
mtime: new Date(item.mtime || Date.now()).toISOString(),
124
watchedBy: {},
126
uploader: '',
125
});
127
downloaders: [],
128
watchedBy: item.watchedBy || {},
129
});
130
};
131
132
const delayMs = Number(metaDelayMsFixture[file] || 0);
133
if (delayMs > 0)
134
{
135
setTimeout(sendMeta, delayMs);
136
return;
137
}
138
139
sendMeta();
126
});
140
});
127
app.post('/api/files/video-stream', (req, res) =>
141
app.post('/api/files/video-stream', (req, res) =>
128
{
142
{
@@ -687,6 +701,90 @@ describe('page load smoke test', () =>687
dom.window.close();
701
dom.window.close();
688
});
702
});
689
703
704
test('rapid file reselection does not duplicate sidebar action buttons after delayed metadata', async () =>
705
{
706
listFixture = {
707
'/data': [
708
{
709
name: 'first.txt',
710
path: '/data/first.txt',
711
isDir: false,
712
size: 10,
713
mtime: Date.now(),
714
},
715
{
716
name: 'second.txt',
717
path: '/data/second.txt',
718
isDir: false,
719
size: 20,
720
mtime: Date.now(),
721
},
722
],
723
};
724
metaDelayMsFixture['/data/first.txt'] = 120;
725
726
const { dom, runtimeErrors } = await bootClient();
727
expect(runtimeErrors).toEqual([]);
728
729
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/first.txt"]'));
730
const firstTile = dom.window.document.querySelector('.file-item[data-path="/data/first.txt"]');
731
const secondTile = dom.window.document.querySelector('.file-item[data-path="/data/second.txt"]');
732
expect(firstTile).toBeTruthy();
733
expect(secondTile).toBeTruthy();
734
735
firstTile.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
736
await new Promise(resolve => dom.window.setTimeout(resolve, 10));
737
secondTile.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
738
739
await new Promise(resolve => dom.window.setTimeout(resolve, 220));
740
741
const actionButtons = Array.from(dom.window.document.querySelectorAll('#sidebar-actions button')).map(b => b.textContent);
742
expect(actionButtons).toEqual(['View / Download', 'Share']);
743
744
dom.window.close();
745
});
746
747
test('video tiles show centred watched overlays for fully and partway statuses', async () =>
748
{
749
listFixture = {
750
'/data': [
751
{
752
name: 'watched-full.mkv',
753
path: '/data/watched-full.mkv',
754
isDir: false,
755
size: 100,
756
mtime: Date.now(),
757
watchedBy: { tester: 'fully' },
758
},
759
{
760
name: 'watched-part.mkv',
761
path: '/data/watched-part.mkv',
762
isDir: false,
763
size: 100,
764
mtime: Date.now(),
765
watchedBy: { tester: 'partway' },
766
},
767
],
768
};
769
770
const { dom, runtimeErrors } = await bootClient();
771
expect(runtimeErrors).toEqual([]);
772
773
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay--fully'));
774
775
const fullOverlayPath = dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay--fully path');
776
const partOverlayPath = dom.window.document.querySelector('.file-item[data-path="/data/watched-part.mkv"] .watched-overlay--partway path');
777
778
expect(fullOverlayPath).toBeTruthy();
779
expect(fullOverlayPath.getAttribute('fill')).toBe('#ffffff');
780
781
expect(partOverlayPath).toBeTruthy();
782
expect(partOverlayPath.getAttribute('fill')).toBe('none');
783
expect(partOverlayPath.getAttribute('stroke')).toBe('#ffffff');
784
785
dom.window.close();
786
});
787
690
test('admin user modal locks write checkbox while read is unchecked', async () =>
788
test('admin user modal locks write checkbox while read is unchecked', async () =>
691
{
789
{
692
meFixture = { username: 'admin', isAdmin: true, permissions: {} };
790
meFixture = { username: 'admin', isAdmin: true, permissions: {} };