fix: My Computer hiển thị cây hệ thống thay vì Favorites session cũ
This commit is contained in:
@@ -9323,36 +9323,6 @@ const MediaExplorerPanel = ({ height }) => {
|
||||
|
||||
const openMyComputer = async () => {
|
||||
setFolder('computer');
|
||||
// Restore last opened folder from session (click My Computer → show folder content directly)
|
||||
try {
|
||||
const raw = localStorage.getItem(SESSION_KEY);
|
||||
if (raw) {
|
||||
const snap = JSON.parse(raw);
|
||||
if (snap && snap.computerPath && snap.computerFiles) {
|
||||
setComputerPath(snap.computerPath);
|
||||
setComputerFiles(snap.computerFiles);
|
||||
setComputerMode(snap.computerMode || 'server');
|
||||
if (snap.computerTree) {
|
||||
const tree = {};
|
||||
Object.keys(snap.computerTree).forEach(p => { tree[p] = { dirs: snap.computerTree[p].dirs || [], expanded: snap.computerTree[p].expanded }; });
|
||||
setComputerTree(tree);
|
||||
}
|
||||
if (snap.computerRoots && snap.computerRoots.length) setComputerRoots(snap.computerRoots);
|
||||
if (snap.selected) setSelected(snap.selected);
|
||||
// For client mode, re-attach real handles by walking from the stored root handle
|
||||
if (snap.computerMode === 'client') {
|
||||
const savedHandle = await loadClientRootHandle();
|
||||
if (savedHandle && savedHandle.kind === 'directory') {
|
||||
setClientRoot(savedHandle);
|
||||
setComputerRoots([{ name: savedHandle.name, path: 'root', is_dir: true, handle: savedHandle }]);
|
||||
setComputerMode('client');
|
||||
browseComputerDir({ name: savedHandle.name, path: 'root', is_dir: true, handle: savedHandle });
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
// Ưu tiên client-side: nếu có root handle đã lưu (File System Access API) → tự động quét cây client
|
||||
let savedHandle = null;
|
||||
try { savedHandle = await loadClientRootHandle(); } catch (e) {}
|
||||
|
||||
Reference in New Issue
Block a user