diff options
| author | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
|---|---|---|
| committer | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
| commit | bce557cc2dc767628bed6aac87301a1be7c5431b (patch) | |
| tree | b51a051228d01fe3306cd7626d4a96768aadb944 /shared/components/src/stores/navigation-folders-open.ts | |
init commit
Diffstat (limited to 'shared/components/src/stores/navigation-folders-open.ts')
| -rw-r--r-- | shared/components/src/stores/navigation-folders-open.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/shared/components/src/stores/navigation-folders-open.ts b/shared/components/src/stores/navigation-folders-open.ts new file mode 100644 index 0000000..b761371 --- /dev/null +++ b/shared/components/src/stores/navigation-folders-open.ts @@ -0,0 +1,21 @@ +import { type Writable, writable } from 'svelte/store'; + +type FolderState = Writable<boolean>; +const folderStates = new Map<string, FolderState>(); + +export function subscribeFolderOpenState( + id: string, + defaultState?: boolean, +): FolderState { + let stateById = folderStates.get(id); + if (!stateById) { + folderStates.set(id, writable(defaultState ?? false)); + stateById = folderStates.get(id); + } + + return stateById; +} + +export function resetFoldersOpenState() { + folderStates.clear(); +} |
