From 4c26abc83d105db89e087abafd6286ad84d63d3f Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 4 Aug 2023 08:41:04 +0100 Subject: [PATCH] Fix reactivity bug with normal user app list --- .../src/pages/builder/apps/index.svelte | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/builder/src/pages/builder/apps/index.svelte b/packages/builder/src/pages/builder/apps/index.svelte index 6b74694c00..ca3617b589 100644 --- a/packages/builder/src/pages/builder/apps/index.svelte +++ b/packages/builder/src/pages/builder/apps/index.svelte @@ -28,25 +28,13 @@ let userInfoModal let changePasswordModal - onMount(async () => { - try { - await organisation.init() - await apps.load() - await groups.actions.init() - } catch (error) { - notifications.error("Error loading apps") - } - loaded = true - }) - const publishedAppsOnly = app => app.status === AppStatus.DEPLOYED - $: userGroups = $groups.filter(group => group.users.find(user => user._id === $auth.user?._id) ) - $: publishedApps = $apps.filter(publishedAppsOnly) - $: userApps = getUserApps($auth.user) + $: publishedApps = $apps.filter(app => app.status === AppStatus.DEPLOYED) + $: userApps = getUserApps(publishedApps, userGroups, $auth.user) - function getUserApps(user) { + function getUserApps(publishedApps, userGroups, user) { if (sdk.users.isAdmin(user)) { return publishedApps } @@ -84,6 +72,17 @@ // Swallow error and do nothing } } + + onMount(async () => { + try { + await organisation.init() + await apps.load() + await groups.actions.init() + } catch (error) { + notifications.error("Error loading apps") + } + loaded = true + }) {#if $auth.user && loaded}