🏡 index : ~doyle/chartered.git

author Jordan Doyle <jordan@doyle.la> 2022-09-10 12:56:34.0 +01:00:00
committer Jordan Doyle <jordan@doyle.la> 2022-09-10 12:56:34.0 +01:00:00
commit
1f232c331c6730891396fbe10fb101336340f3c6 [patch]
tree
cd500c826c2f37db856c78337658a323955506a8
parent
cdcf6781095158278ddf4c6e3e67657f36b6c90d
download
1f232c331c6730891396fbe10fb101336340f3c6.tar.gz

Abstract out allTabs mutation so it doesn't end in a reactive infinite loop



Diff

 chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.svelte         | 10 +++++++++-
 chartered-frontend/src/routes/(authed)/crates/[organisation]/[crate]/+page.svelte | 10 +++++++++-
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.svelte b/chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.svelte
index 408c393..2ff9192 100644
--- a/chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.svelte
+++ a/chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.svelte
@@ -50,7 +50,13 @@
    // binding to the current tab the user has selected
    let currentTab = Tab.CRATES;

    $: organisationPromise.then((org) => {
    $: organisationPromise.then(filterTabsForOrg);

    /**
     * Filters the tabs displayed to the user depending on their current permissions for the
     * organisation.
     */
    function filterTabsForOrg(org: CrateMembers) {
        if (org.members) {
            // user has access to the member page but the tab isn't currently being shown, so we should
            // add it
@@ -75,7 +81,7 @@
                currentTab = Tab.CRATES;
            }
        }
    });
    }

    // contains the member the user is currently considering adding to the org & has not yet persisted to
    // the server.
diff --git a/chartered-frontend/src/routes/(authed)/crates/[organisation]/[crate]/+page.svelte b/chartered-frontend/src/routes/(authed)/crates/[organisation]/[crate]/+page.svelte
index d3a22c4..501024e 100644
--- a/chartered-frontend/src/routes/(authed)/crates/[organisation]/[crate]/+page.svelte
+++ a/chartered-frontend/src/routes/(authed)/crates/[organisation]/[crate]/+page.svelte
@@ -42,7 +42,13 @@
    // binding to the current tab the user has selected
    let currentTab = Tab.README;

    $: cratePromise.then((crate) => {
    $: cratePromise.then(filterTabsForCrate);

    /**
     * Filters the tabs displayed to the user depending on their current permissions for the
     * crate.
     */
    function filterTabsForCrate(crate: Crate) {
        if (crate.permissions.includes('MANAGE_USERS')) {
            // user has access to the member page but the tab isn't currently being shown, so we should
            // add it
@@ -67,7 +73,7 @@
                currentTab = Tab.README;
            }
        }
    });
    }
</script>

<header>