From 95dc555ee3a02577056c39c701b2fdf08a107043 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 2 Apr 2024 17:23:12 +0200 Subject: [PATCH 1/4] fix: race condition during invalidation --- .../function-[function]/settings/+page.svelte | 11 +++++------ .../console/project-[project]/updateVariables.svelte | 8 +++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte index 4dac5f427..2384dc1bd 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte @@ -24,21 +24,20 @@ const sdkCreateVariable = async (key: string, value: string) => { await sdk.forProject.functions.createVariable($func.$id, key, value); - await invalidate(Dependencies.VARIABLES); - await invalidate(Dependencies.FUNCTION); + await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]); }; const sdkUpdateVariable = async (variableId: string, key: string, value: string) => { await sdk.forProject.functions.updateVariable($func.$id, variableId, key, value); - await invalidate(Dependencies.VARIABLES); - await invalidate(Dependencies.FUNCTION); + await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]); }; const sdkDeleteVariable = async (variableId: string) => { await sdk.forProject.functions.deleteVariable($func.$id, variableId); - await invalidate(Dependencies.VARIABLES); - await invalidate(Dependencies.FUNCTION); + await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]); }; + + $: console.log(data.variables); diff --git a/src/routes/console/project-[project]/updateVariables.svelte b/src/routes/console/project-[project]/updateVariables.svelte index 8a17fa61d..892ed7ef4 100644 --- a/src/routes/console/project-[project]/updateVariables.svelte +++ b/src/routes/console/project-[project]/updateVariables.svelte @@ -138,9 +138,11 @@ selectedVar = null; showPromoteModal = false; - await invalidate(Dependencies.FUNCTION); - await invalidate(Dependencies.VARIABLES); - await invalidate(Dependencies.PROJECT_VARIABLES); + await Promise.all([ + await invalidate(Dependencies.FUNCTION), + await invalidate(Dependencies.VARIABLES), + await invalidate(Dependencies.PROJECT_VARIABLES) + ]); addNotification({ type: 'success', From 230a7621b446d9f5976b383b722b781a4deabb00 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 2 Apr 2024 17:23:49 +0200 Subject: [PATCH 2/4] remove console log --- .../functions/function-[function]/settings/+page.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte index 2384dc1bd..db5149a6a 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte @@ -36,8 +36,6 @@ await sdk.forProject.functions.deleteVariable($func.$id, variableId); await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]); }; - - $: console.log(data.variables); From d4d43b678b80fd5708926538009565441917d0df Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 9 Apr 2024 09:56:50 +0200 Subject: [PATCH 3/4] Update src/routes/console/project-[project]/updateVariables.svelte Co-authored-by: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> --- src/routes/console/project-[project]/updateVariables.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/console/project-[project]/updateVariables.svelte b/src/routes/console/project-[project]/updateVariables.svelte index 892ed7ef4..035d4c480 100644 --- a/src/routes/console/project-[project]/updateVariables.svelte +++ b/src/routes/console/project-[project]/updateVariables.svelte @@ -139,9 +139,9 @@ showPromoteModal = false; await Promise.all([ - await invalidate(Dependencies.FUNCTION), - await invalidate(Dependencies.VARIABLES), - await invalidate(Dependencies.PROJECT_VARIABLES) + invalidate(Dependencies.FUNCTION), + invalidate(Dependencies.VARIABLES), + invalidate(Dependencies.PROJECT_VARIABLES) ]); addNotification({ From 4d88ef4dd5ea7fa191868a09f7db04d2a6d6ab2f Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 9 Apr 2024 10:01:01 +0200 Subject: [PATCH 4/4] chore: linter --- src/routes/console/project-[project]/updateVariables.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/console/project-[project]/updateVariables.svelte b/src/routes/console/project-[project]/updateVariables.svelte index 035d4c480..7396219fa 100644 --- a/src/routes/console/project-[project]/updateVariables.svelte +++ b/src/routes/console/project-[project]/updateVariables.svelte @@ -139,9 +139,9 @@ showPromoteModal = false; await Promise.all([ - invalidate(Dependencies.FUNCTION), - invalidate(Dependencies.VARIABLES), - invalidate(Dependencies.PROJECT_VARIABLES) + invalidate(Dependencies.FUNCTION), + invalidate(Dependencies.VARIABLES), + invalidate(Dependencies.PROJECT_VARIABLES) ]); addNotification({