refactor(web): folders store (#14305)

* refactor(web): folders store

* use typescript private
This commit is contained in:
Michel Heusschen
2024-11-23 20:22:13 +01:00
committed by GitHub
parent 454836b551
commit c33b918d74
7 changed files with 52 additions and 81 deletions
@@ -1,10 +1,9 @@
import { QueryParameter } from '$lib/constants';
import { foldersStore } from '$lib/stores/folders.store';
import { foldersStore } from '$lib/stores/folders.svelte';
import { authenticate } from '$lib/utils/auth';
import { getFormatter } from '$lib/utils/i18n';
import { getAssetInfoFromParam } from '$lib/utils/navigation';
import { buildTree, normalizeTreePath } from '$lib/utils/tree-utils';
import { get } from 'svelte/store';
import type { PageLoad } from './$types';
export const load = (async ({ params, url }) => {
@@ -13,18 +12,16 @@ export const load = (async ({ params, url }) => {
const $t = await getFormatter();
await foldersStore.fetchUniquePaths();
const { uniquePaths } = get(foldersStore);
let pathAssets = null;
const path = url.searchParams.get(QueryParameter.PATH);
if (path) {
await foldersStore.fetchAssetsByPath(path);
const { assets } = get(foldersStore);
pathAssets = assets[path] || null;
pathAssets = foldersStore.assets[path] || null;
}
let tree = buildTree(uniquePaths || []);
let tree = buildTree(foldersStore.uniquePaths);
const parts = normalizeTreePath(path || '').split('/');
for (const part of parts) {
tree = tree?.[part];