Fix workspace selection logic and update settings initialization conditions

This commit is contained in:
2025-10-11 19:04:08 +02:00
parent bcc5d2588a
commit 769385d8c7
2 changed files with 4 additions and 6 deletions

View File

@@ -110,10 +110,10 @@ const WorkspaceSwitcher: React.FC = () => {
</Center> </Center>
) : ( ) : (
workspaces.map((workspace) => { workspaces.map((workspace) => {
const isSelected = workspace.name === currentWorkspace?.name; const isSelected = workspace.id === currentWorkspace?.id;
return ( return (
<Paper <Paper
key={workspace.name} key={workspace.id}
p="xs" p="xs"
withBorder withBorder
style={(theme) => style={(theme) =>

View File

@@ -75,11 +75,9 @@ const WorkspaceSettings: React.FC = () => {
const { currentWorkspace, updateSettings, updateColorScheme, colorScheme } = useWorkspace(); const { currentWorkspace, updateSettings, updateColorScheme, colorScheme } = useWorkspace();
const { settingsModalVisible, setSettingsModalVisible } = useModalContext(); const { settingsModalVisible, setSettingsModalVisible } = useModalContext();
const [state, dispatch] = useReducer(settingsReducer, initialState); const [state, dispatch] = useReducer(settingsReducer, initialState);
const isInitialMount = useRef<boolean>(true);
useEffect(() => { useEffect(() => {
if (isInitialMount.current && currentWorkspace) { if (currentWorkspace && settingsModalVisible) {
isInitialMount.current = false;
const settings: Partial<Workspace> = { const settings: Partial<Workspace> = {
name: currentWorkspace.name, name: currentWorkspace.name,
theme: currentWorkspace.theme, theme: currentWorkspace.theme,
@@ -96,7 +94,7 @@ const WorkspaceSettings: React.FC = () => {
}; };
dispatch({ type: SettingsActionType.INIT_SETTINGS, payload: settings }); dispatch({ type: SettingsActionType.INIT_SETTINGS, payload: settings });
} }
}, [currentWorkspace]); }, [currentWorkspace, settingsModalVisible]);
const handleInputChange = useCallback( const handleInputChange = useCallback(
<K extends keyof Workspace>(key: K, value: Workspace[K]): void => { <K extends keyof Workspace>(key: K, value: Workspace[K]): void => {