mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-10-18 07:03:06 -04:00
* fix things * added back/forward buttons to settings * split top bar context into left and right * hook up path * fix background jobs hidden from job manager * core * fix type + quick preview transition * fix selected item color contrast * fix close button on quick preview * clean up job ui for light theme * Improve media view overscan --------- Co-authored-by: Brendan Allan <brendonovich@outlook.com>
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { proxy, useSnapshot } from 'valtio';
|
|
import { ExplorerItem, FilePathSearchOrdering } from '@sd/client';
|
|
import { resetStore } from '@sd/client/src/stores/util';
|
|
|
|
type UnionKeys<T> = T extends any ? keyof T : never;
|
|
|
|
export type ExplorerLayoutMode = 'rows' | 'grid' | 'columns' | 'media';
|
|
|
|
export enum ExplorerKind {
|
|
Location,
|
|
Tag,
|
|
Space
|
|
}
|
|
|
|
export type CutCopyType = 'Cut' | 'Copy';
|
|
|
|
export type ExplorerOrderByKeys = UnionKeys<FilePathSearchOrdering> | 'none';
|
|
|
|
export type ExplorerDirection = 'asc' | 'desc';
|
|
|
|
const state = {
|
|
locationId: null as number | null,
|
|
layoutMode: 'grid' as ExplorerLayoutMode,
|
|
gridItemSize: 100,
|
|
listItemSize: 40,
|
|
selectedRowIndex: 1 as number | null,
|
|
showBytesInGridView: true,
|
|
tagAssignMode: false,
|
|
showInspector: false,
|
|
multiSelectIndexes: [] as number[],
|
|
newThumbnails: {} as Record<string, boolean | undefined>,
|
|
cutCopyState: {
|
|
sourcePath: '', // this is used solely for preventing copy/cutting to the same path (as that will truncate the file)
|
|
sourceLocationId: 0,
|
|
sourcePathId: 0,
|
|
actionType: 'Cut',
|
|
active: false
|
|
},
|
|
quickViewObject: null as ExplorerItem | null,
|
|
isRenaming: false,
|
|
mediaColumns: 8,
|
|
mediaAspectSquare: true,
|
|
orderBy: 'dateCreated' as ExplorerOrderByKeys,
|
|
orderByDirection: 'desc' as ExplorerDirection,
|
|
groupBy: 'none',
|
|
};
|
|
|
|
// Keep the private and use `useExplorerState` or `getExplorerStore` or you will get production build issues.
|
|
const explorerStore = proxy({
|
|
...state,
|
|
reset: () => resetStore(explorerStore, state),
|
|
addNewThumbnail: (casId: string) => {
|
|
explorerStore.newThumbnails[casId] = true;
|
|
}
|
|
});
|
|
|
|
export function useExplorerStore() {
|
|
return useSnapshot(explorerStore);
|
|
}
|
|
|
|
export function getExplorerStore() {
|
|
return explorerStore;
|
|
}
|