diff --git a/web/src/lib/components/shared-components/tree/tree-items.svelte b/web/src/lib/components/shared-components/tree/tree-items.svelte
index e41d3361ef..6b3b7feda7 100644
--- a/web/src/lib/components/shared-components/tree/tree-items.svelte
+++ b/web/src/lib/components/shared-components/tree/tree-items.svelte
@@ -12,14 +12,12 @@
{#each Object.entries(items) as [path, tree]}
- {#if path !== '\0'}
- {@const value = joinPaths(parent, path)}
- {@const key = value + getColor(value)}
- {#key key}
- -
-
-
- {/key}
- {/if}
+ {@const value = joinPaths(parent, path)}
+ {@const key = value + getColor(value)}
+ {#key key}
+ -
+
+
+ {/key}
{/each}
diff --git a/web/src/lib/utils/tree-utils.ts b/web/src/lib/utils/tree-utils.ts
index fac85e9333..89c1e125a9 100644
--- a/web/src/lib/utils/tree-utils.ts
+++ b/web/src/lib/utils/tree-utils.ts
@@ -1,5 +1,5 @@
export type RecursiveObject = {
- [key: string]: RecursiveObject;
+ [key: string | symbol]: RecursiveObject;
};
export const normalizeTreePath = (path: string) => (path.at(-1) === '/' && path.length > 1 ? path.slice(0, -1) : path);
@@ -32,14 +32,14 @@ export const getParentPath = (path: string) => {
};
export const isLeaf = (tree: RecursiveObject) => {
- for (const entry in tree) {
- if (entry !== '\0') {
- return false;
- }
+ for (const _ in tree) {
+ return false;
}
return true;
};
+export const FOLDER_WITH_ASSETS_SYMBOL = Symbol('folder-with-assets');
+
export function buildTree(paths: string[]): RecursiveObject {
const root: RecursiveObject = {};
@@ -52,7 +52,7 @@ export function buildTree(paths: string[]): RecursiveObject {
}
current = current[part];
}
- current['\0'] = {}; // mark as leaf
+ current[FOLDER_WITH_ASSETS_SYMBOL] = {};
}
return root;
}
diff --git a/web/src/routes/(user)/folders/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/folders/[[photos=photos]]/[[assetId=id]]/+page.ts
index 088a7ac1fa..4bff285d2d 100644
--- a/web/src/routes/(user)/folders/[[photos=photos]]/[[assetId=id]]/+page.ts
+++ b/web/src/routes/(user)/folders/[[photos=photos]]/[[assetId=id]]/+page.ts
@@ -3,7 +3,7 @@ import { foldersStore } from '$lib/stores/folders.store';
import { authenticate } from '$lib/utils/auth';
import { getFormatter } from '$lib/utils/i18n';
import { getAssetInfoFromParam } from '$lib/utils/navigation';
-import { getPathParts, normalizeTreePath } from '$lib/utils/tree-utils';
+import { FOLDER_WITH_ASSETS_SYMBOL, getPathParts, normalizeTreePath } from '$lib/utils/tree-utils';
import type { PageLoad } from './$types';
export const load = (async ({ params, url }) => {
@@ -27,7 +27,7 @@ export const load = (async ({ params, url }) => {
}
// only fetch assets if the folder has assets
- if (tree['\0']) {
+ if (tree[FOLDER_WITH_ASSETS_SYMBOL]) {
const { assets } = await foldersStore.fetchAssetsByPath(path);
pathAssets = assets[path] || null;
}
@@ -36,7 +36,7 @@ export const load = (async ({ params, url }) => {
return {
asset,
path,
- currentFolders: Object.keys(tree || {}).filter((name) => name !== '\0'),
+ currentFolders: Object.keys(tree || {}),
pathAssets,
meta: {
title: $t('folders'),