mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 23:18:06 -04:00
* New functions to open ephemeral files * Review items for ephemeral files * Open and OpenWith context menu for ephemeral paths * Some warnings * Fixing inspector * Fixing windows * Format * Messy rebase * Fix macos * Cargo fmt * Removing devtools as it can be opened with keybind * Fix macos * Separating ext for ephemeral files on inspector * Fixing bad rebase * Removing rename button from quickpreview for ephemeral files * Quick Preview for ephemeral files * Requested changes
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { createContext, PropsWithChildren, useContext } from 'react';
|
|
import {
|
|
ExplorerItem,
|
|
FilePath,
|
|
NonIndexedPathItem,
|
|
Object,
|
|
useItemsAsEphemeralPaths,
|
|
useItemsAsFilePaths,
|
|
useItemsAsObjects
|
|
} from '@sd/client';
|
|
import { NonEmptyArray } from '~/util';
|
|
|
|
const ContextMenuContext = createContext<{
|
|
selectedItems: NonEmptyArray<ExplorerItem>;
|
|
selectedFilePaths: FilePath[];
|
|
selectedObjects: Object[];
|
|
selectedEphemeralPaths: NonIndexedPathItem[];
|
|
} | null>(null);
|
|
|
|
export const ContextMenuContextProvider = ({
|
|
selectedItems,
|
|
children
|
|
}: PropsWithChildren<{
|
|
selectedItems: NonEmptyArray<ExplorerItem>;
|
|
}>) => {
|
|
const selectedFilePaths = useItemsAsFilePaths(selectedItems);
|
|
const selectedObjects = useItemsAsObjects(selectedItems);
|
|
const selectedEphemeralPaths = useItemsAsEphemeralPaths(selectedItems);
|
|
|
|
return (
|
|
<ContextMenuContext.Provider
|
|
value={{ selectedItems, selectedFilePaths, selectedObjects, selectedEphemeralPaths }}
|
|
>
|
|
{children}
|
|
</ContextMenuContext.Provider>
|
|
);
|
|
};
|
|
|
|
export const useContextMenuContext = () => {
|
|
const context = useContext(ContextMenuContext);
|
|
if (!context) throw new Error('ContextMenuContext.Provider not found');
|
|
return context;
|
|
};
|