From 089e698d43d7883bf27ac73bb992f1b3507d92fb Mon Sep 17 00:00:00 2001 From: Alexander Petric Date: Fri, 10 Jan 2025 13:33:45 -0500 Subject: [PATCH] workspace color fixes part2 (#5045) * fix workspace color picker issue * removing useless reactive statement * some ui fixes --- .../settings/ChangeWorkspaceColor.svelte | 24 ++++++++++++++----- .../components/sidebar/WorkspaceMenu.svelte | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) 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

- {#if workspaceColor} + {#if savedWorkspaceColor}
{:else} No color set @@ -72,7 +82,9 @@ Workspace color
- + {#if colorEnabled} + + {/if} -
+
{workspace.name}