Update Workspace Settings on frontend

This commit is contained in:
2024-10-27 16:53:15 +01:00
parent 4544af8f0f
commit 17c03c2d14
4 changed files with 43 additions and 47 deletions

View File

@@ -44,7 +44,7 @@ function settingsReducer(state, action) {
}
const Settings = () => {
const { settings, updateSettings } = useWorkspace();
const { currentWorkspace, updateSettings } = useWorkspace();
const { settingsModalVisible, setSettingsModalVisible } = useModalContext();
const [state, dispatch] = useReducer(settingsReducer, initialState);
const isInitialMount = useRef(true);
@@ -52,9 +52,19 @@ const Settings = () => {
useEffect(() => {
if (isInitialMount.current) {
isInitialMount.current = false;
const settings = {
theme: currentWorkspace.theme,
autoSave: currentWorkspace.autoSave,
gitEnabled: currentWorkspace.gitEnabled,
gitUrl: currentWorkspace.gitUrl,
gitUser: currentWorkspace.gitUser,
gitToken: currentWorkspace.gitToken,
gitAutoCommit: currentWorkspace.gitAutoCommit,
gitCommitMsgTemplate: currentWorkspace.gitCommitMsgTemplate,
};
dispatch({ type: 'INIT_SETTINGS', payload: settings });
}
}, [settings]);
}, [currentWorkspace]);
const handleInputChange = useCallback((key, value) => {
dispatch({ type: 'UPDATE_LOCAL_SETTINGS', payload: { [key]: value } });