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(-)
@@ -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.
@@ -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>