Refactor WorkspaceDataContext and useFileOperations to remove settings

This commit is contained in:
2025-07-11 23:53:37 +02:00
parent e1760ccd82
commit 0b0cd9160e
6 changed files with 53 additions and 76 deletions

View File

@@ -10,10 +10,14 @@ interface UseGitOperationsResult {
}
export const useGitOperations = (): UseGitOperationsResult => {
const { currentWorkspace, settings } = useWorkspaceData();
const { currentWorkspace } = useWorkspaceData();
const handlePull = useCallback(async (): Promise<boolean> => {
if (!currentWorkspace || !settings.gitEnabled || !currentWorkspace.name)
if (
!currentWorkspace ||
!currentWorkspace.gitEnabled ||
!currentWorkspace.name
)
return false;
try {
@@ -33,11 +37,11 @@ export const useGitOperations = (): UseGitOperationsResult => {
});
return false;
}
}, [currentWorkspace, settings.gitEnabled]);
}, [currentWorkspace]);
const handleCommitAndPush = useCallback(
async (message: string): Promise<void> => {
if (!currentWorkspace || !settings.gitEnabled) return;
if (!currentWorkspace || !currentWorkspace.gitEnabled) return;
try {
const commitHash: CommitHash = await commitAndPush(
@@ -60,7 +64,7 @@ export const useGitOperations = (): UseGitOperationsResult => {
return;
}
},
[currentWorkspace, settings.gitEnabled]
[currentWorkspace]
);
return { handlePull, handleCommitAndPush };