mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-08 00:44:22 +00:00
Remove FileList, FileOps and GitOps contexts
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
import React, { createContext, useContext, useMemo } from 'react';
|
||||
import { useFileList } from '../hooks/useFileList';
|
||||
|
||||
const FileListContext = createContext();
|
||||
|
||||
export const FileListProvider = ({ children }) => {
|
||||
const { files, loadFileList } = useFileList();
|
||||
|
||||
const value = useMemo(() => ({ files, loadFileList }), [files, loadFileList]);
|
||||
|
||||
return (
|
||||
<FileListContext.Provider value={value}>
|
||||
{children}
|
||||
</FileListContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useFileListContext = () => {
|
||||
const context = useContext(FileListContext);
|
||||
if (context === undefined) {
|
||||
throw new Error(
|
||||
'useFileListContext must be used within a FileListProvider'
|
||||
);
|
||||
}
|
||||
return context;
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
import React, { createContext, useContext, useMemo } from 'react';
|
||||
import { useFileContent } from '../hooks/useFileContent';
|
||||
|
||||
const FileOperationsContext = createContext();
|
||||
|
||||
export const FileOperationsProvider = ({ children }) => {
|
||||
const { handleCreateNewFile, handleDeleteFile } = useFileContent();
|
||||
|
||||
const value = useMemo(
|
||||
() => ({
|
||||
handleCreateNewFile,
|
||||
handleDeleteFile,
|
||||
}),
|
||||
[handleCreateNewFile, handleDeleteFile]
|
||||
);
|
||||
|
||||
return (
|
||||
<FileOperationsContext.Provider value={value}>
|
||||
{children}
|
||||
</FileOperationsContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useFileOperations = () => {
|
||||
const context = useContext(FileOperationsContext);
|
||||
if (context === undefined) {
|
||||
throw new Error(
|
||||
'useFileOperations must be used within a FileOperationsProvider'
|
||||
);
|
||||
}
|
||||
return context;
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { useGitOperations } from '../hooks/useGitOperations';
|
||||
|
||||
const GitOperationsContext = createContext();
|
||||
|
||||
export const GitOperationsProvider = ({ children }) => {
|
||||
const gitOperationsHook = useGitOperations();
|
||||
|
||||
return (
|
||||
<GitOperationsContext.Provider value={gitOperationsHook}>
|
||||
{children}
|
||||
</GitOperationsContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useGitOperationsContext = () => {
|
||||
const context = useContext(GitOperationsContext);
|
||||
if (!context) {
|
||||
throw new Error(
|
||||
'useGitOperationsContext must be used within a GitOperationsProvider'
|
||||
);
|
||||
}
|
||||
return context;
|
||||
};
|
||||
Reference in New Issue
Block a user