Refine: virtual locations

- Make drive list change reactive
This commit is contained in:
aleksey-hoffman committed 2026-06-30 16:27:08 +03:00
1 parent 76396fdab2
commit a6289a9d53
2 files changed
+27 -9

No files matched your search

@@ -46,11 +46,11 @@ import { useShortcutsStore } from '@/stores/runtime/shortcuts';
import { usePlatformStore } from '@/stores/runtime/platform';
import normalizePath, { getPathDisplayName, getPathSegments, isUncPath } from '@/utils/normalize-path';
import {
getLocationsDrivePaths,
isVirtualLocationPath,
LOCATIONS_VIRTUAL_PATH,
shouldPrependLocationsCrumb,
} from '@/utils/virtual-locations';
import { useDrives } from '@/modules/home/composables/use-drives';
import { useOpenCopiedPath } from './composables/use-open-copied-path';
const props = defineProps<{
@@ -66,6 +66,8 @@ const emit = defineEmits<{
const { t } = useI18n();
const shortcutsStore = useShortcutsStore();
const platformStore = usePlatformStore();
const { drives } = useDrives();
const locationsDrivePaths = computed(() => drives.value.map(drive => normalizePath(drive.path)));
const { openCopiedPath } = useOpenCopiedPath({
openDirectory: path => emit('navigate', path),
openFile: path => emit('openFile', path),
@@ -161,13 +163,6 @@ async function loadSeparatorDirectories(index: number) {
if (!part) return;
if (part.virtual) {
try {
separatorDropdowns.value[index] = await getLocationsDrivePaths();
}
catch {
separatorDropdowns.value[index] = [];
}
return;
}
@@ -359,7 +354,7 @@ onUnmounted(() => {
class="address-bar__separator-menu-scroll"
>
<DropdownMenuItem
v-for="dirPath in separatorDropdowns[index]"
v-for="dirPath in part.virtual ? locationsDrivePaths : separatorDropdowns[index]"
:key="dirPath"
@select="handleSeparatorNavigate(dirPath)"
>
@@ -34,6 +34,7 @@ import {
isVirtualLocationPath,
resolveDirectoryContents,
} from '@/utils/virtual-locations';
import { sharedDrives } from '@/modules/home/composables/use-drives';
import { shouldIncludeItemCountsForSort } from '@/modules/navigator/components/file-browser/utils/file-browser-sort-columns';
interface DirChangePayload {
@@ -45,6 +46,13 @@ interface DirChangePayload {
const DIRECTORY_DWELL_TIME_MS = 3000;
const WATCHER_DEBOUNCE_MS = 500;
function getDrivePathListSignature(paths: string[]): string {
return paths
.map(path => normalizePath(path))
.sort()
.join('\0');
}
function dirWatcherDiagEnabled(): boolean {
return import.meta.env.DEV && localStorage.getItem('SFM_DIR_WATCHER_DIAG') === '1';
}
@@ -253,6 +261,21 @@ export function useFileBrowserNavigation(
}
}
watch(sharedDrives, () => {
if (!isVirtualLocationPath(currentPath.value) || !dirContents.value) {
return;
}
const displayedDrivePaths = dirContents.value.entries.map(entry => entry.path);
const liveDrivePaths = sharedDrives.value.map(drive => drive.path);
if (getDrivePathListSignature(displayedDrivePaths) === getDrivePathListSignature(liveDrivePaths)) {
return;
}
void silentRefresh();
}, { deep: true });
onUnmounted(() => {
cancelPendingDirectoryRecord();
stopWatching();