diff --git a/frontend/src/lib/components/settings/ChangeWorkspaceColor.svelte b/frontend/src/lib/components/settings/ChangeWorkspaceColor.svelte index a99862d306178..bf5a85120ec50 100644 --- a/frontend/src/lib/components/settings/ChangeWorkspaceColor.svelte +++ b/frontend/src/lib/components/settings/ChangeWorkspaceColor.svelte @@ -8,10 +8,21 @@ import Toggle from '$lib/components/Toggle.svelte' let colorEnabled = false - let workspaceColor = $usersWorkspaceStore?.workspaces.find(w => w.id === $workspaceStore)?.color + let workspaceColor: string | undefined = undefined + let savedWorkspaceColor: string | undefined = undefined + let lastWorkspace: string | undefined = undefined export let open = false + $: if ($usersWorkspaceStore && $workspaceStore !== lastWorkspace) { + lastWorkspace = $workspaceStore + savedWorkspaceColor = $usersWorkspaceStore.workspaces.find( + (w) => w.id === $workspaceStore + )?.color + workspaceColor = savedWorkspaceColor + } + + $: colorEnabled = !!workspaceColor $: if (colorEnabled && !workspaceColor) generateRandomColor() function generateRandomColor() { @@ -34,8 +45,7 @@ }) usersWorkspaceStore.set(await WorkspaceService.listUserWorkspaces()) - workspaceColor = colorToSave - + savedWorkspaceColor = colorToSave sendUserToast(`Workspace color updated.`) } @@ -43,10 +53,10 @@
Workspace Color