Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: org presistency when switchin org #671

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/routes/console/organization-[organization]/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Header from './header.svelte';
import { headerAlert } from '$lib/stores/headerAlert';
import ProjectsAtRisk from '$lib/components/billing/alerts/projectsAtRisk.svelte';
import { get } from 'svelte/store';
import { preferences } from '$lib/stores/preferences';

export const load: LayoutLoad = async ({ params, depends }) => {
depends(Dependencies.ORGANIZATION);
Expand All @@ -28,13 +29,20 @@ export const load: LayoutLoad = async ({ params, depends }) => {
}

try {
const prefs = await sdk.forConsole.account.getPrefs();
const newPrefs = { ...prefs, organization: params.organization };
sdk.forConsole.account.updatePrefs(newPrefs);
preferences.loadTeamPrefs(params.organization);
return {
header: Header,
breadcrumbs: Breadcrumbs,
organization: await sdk.forConsole.teams.get(params.organization),
members: await sdk.forConsole.teams.listMemberships(params.organization)
};
} catch (e) {
const prefs = await sdk.forConsole.account.getPrefs();
const newPrefs = { ...prefs, organization: '' };
sdk.forConsole.account.updatePrefs(newPrefs);
localStorage.removeItem('organization');
throw error(e.code, e.message);
}
Expand Down