mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-19 13:55:40 -04:00
[ENG-989] Switch explorer views bug (#1433)
* Fix explorer switching bug * tweaks
This commit is contained in:
@@ -81,20 +81,29 @@ export type UseExplorer<TOrder extends Ordering> = ReturnType<typeof useExplorer
|
||||
export function useExplorerSettings<TOrder extends Ordering>({
|
||||
settings,
|
||||
onSettingsChanged,
|
||||
orderingKeys
|
||||
orderingKeys,
|
||||
location
|
||||
}: {
|
||||
settings: ReturnType<typeof createDefaultExplorerSettings<TOrder>>;
|
||||
onSettingsChanged?: (settings: ExplorerSettings<TOrder>) => any;
|
||||
orderingKeys?: z.ZodUnion<
|
||||
[z.ZodLiteral<OrderingKeys<TOrder>>, ...z.ZodLiteral<OrderingKeys<TOrder>>[]]
|
||||
>;
|
||||
location?: Location | null;
|
||||
}) {
|
||||
const [store] = useState(() => proxy(settings));
|
||||
|
||||
useEffect(() => {
|
||||
Object.assign(store, settings);
|
||||
Object.assign(store, {
|
||||
...settings,
|
||||
layoutMode: store.layoutMode
|
||||
});
|
||||
}, [store, settings]);
|
||||
|
||||
useEffect(() => {
|
||||
store.layoutMode = settings.layoutMode;
|
||||
}, [location])
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
subscribe(store, () => {
|
||||
|
||||
@@ -74,7 +74,8 @@ export const Component = () => {
|
||||
const explorerSettings = useExplorerSettings({
|
||||
settings,
|
||||
onSettingsChanged,
|
||||
orderingKeys: filePathOrderingKeysSchema
|
||||
orderingKeys: filePathOrderingKeysSchema,
|
||||
location: location.data
|
||||
});
|
||||
|
||||
const { items, count, loadMore, query } = useItems({ locationId, settings: explorerSettings });
|
||||
|
||||
Reference in New Issue
Block a user