selection cleanup

This commit is contained in:
2025-11-19 00:57:06 +01:00
parent 1764f24243
commit 6923a68837
5 changed files with 39 additions and 20 deletions
+4 -8
View File
@@ -6,7 +6,6 @@ import UploadQueueOverlay from './UploadQueueOverlay';
import useDocumentsWorkspace from '../hooks/documents/useDocumentsWorkspace';
import { useDocumentsPreferences } from './useDocumentsPreferences';
import SettingsRoute from './SettingsRoute';
import { WorkspaceSelectionProvider } from './WorkspaceSelectionContext';
const AppLayout: React.FC = () => {
const documentsPreferences = useDocumentsPreferences();
@@ -17,7 +16,6 @@ const AppLayout: React.FC = () => {
dropOverlayState,
managementModals,
contextValue,
workspaceSelection,
settingsOpen,
closeSettings,
} = useDocumentsWorkspace({
@@ -47,9 +45,8 @@ const AppLayout: React.FC = () => {
}
return (
<WorkspaceSelectionProvider value={workspaceSelection}>
<AppShellContext.Provider value={contextValue}>
<div className="app-shell" ref={shellRef}>
<AppShellContext.Provider value={contextValue}>
<div className="app-shell" ref={shellRef}>
<DropOverlay
active={dropOverlayState.active}
folderName={dropOverlayState.folderName}
@@ -63,9 +60,8 @@ const AppLayout: React.FC = () => {
{settingsOpen ? (
<SettingsRoute open onClose={closeSettings} />
) : null}
</div>
</AppShellContext.Provider>
</WorkspaceSelectionProvider>
</div>
</AppShellContext.Provider>
);
};
+12 -8
View File
@@ -1,16 +1,20 @@
import React, { createContext, useContext } from 'react';
import type useWorkspaceSelection from './useWorkspaceSelection';
type WorkspaceSelectionValue = ReturnType<typeof useWorkspaceSelection> | null;
export type WorkspaceSelectionValue = ReturnType<typeof useWorkspaceSelection>;
const WorkspaceSelectionContext = createContext<WorkspaceSelectionValue>(null);
const WorkspaceSelectionContext = createContext<WorkspaceSelectionValue | null>(null);
export const WorkspaceSelectionProvider: React.FC<{ value: NonNullable<WorkspaceSelectionValue>; children: React.ReactNode }>
= ({ value, children }) => (
<WorkspaceSelectionContext.Provider value={value}>
{children}
</WorkspaceSelectionContext.Provider>
);
interface WorkspaceSelectionProviderProps {
value: WorkspaceSelectionValue;
children: React.ReactNode;
}
export const WorkspaceSelectionProvider: React.FC<WorkspaceSelectionProviderProps> = ({ value, children }) => (
<WorkspaceSelectionContext.Provider value={value}>
{children}
</WorkspaceSelectionContext.Provider>
);
export const useWorkspaceSelectionContext = () => {
const context = useContext(WorkspaceSelectionContext);