Speed up note switcher and sync window scaling

This commit is contained in:
Yuri Karamian
2026-08-07 16:51:06 +02:00
parent 7ca226d918
commit 73f7604187
7 changed files with 248 additions and 18 deletions
+24 -3
View File
@@ -28,6 +28,27 @@ function pathKey(path: string): string {
return path.replace(/\\/g, '/');
}
export function buildNoteSwitcherRequestPaths(
currentPath: string | null,
historyPaths: readonly string[]
): string[] {
const paths: string[] = [];
const seen = new Set<string>();
const addPath = (path: string | null) => {
if (!path) return;
const key = pathKey(path);
if (seen.has(key)) return;
seen.add(key);
paths.push(path);
};
addPath(currentPath);
for (let index = historyPaths.length - 1; index >= 0; index -= 1) {
addPath(historyPaths[index]);
}
return paths;
}
function folderLabel(relativePath: string): string {
const parts = relativePath.replace(/\\/g, '/').split('/').filter(Boolean);
parts.pop();
@@ -66,9 +87,9 @@ export function buildNoteSwitcherSections({
recent.push(toRow(note, currentPathKey));
};
addRecent(currentPath);
for (let index = historyPaths.length - 1; index >= 0 && recent.length < limit; index -= 1) {
addRecent(historyPaths[index]);
for (const path of buildNoteSwitcherRequestPaths(currentPath, historyPaths)) {
if (recent.length >= limit) break;
addRecent(path);
}
const quickAccess: NoteSwitcherRow[] = [];