mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 23:44:22 +00:00
Fix workspace selection logic and update settings initialization conditions
This commit is contained in:
@@ -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) =>
|
||||||
|
|||||||
@@ -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 => {
|
||||||
|
|||||||
Reference in New Issue
Block a user