Skip to content

Commit

Permalink
Merge pull request #622 from appwrite/fix-last-org
Browse files Browse the repository at this point in the history
fix: move last org to account prefs
  • Loading branch information
TorstenDittmann authored Nov 16, 2023
2 parents 49d039e + 83a0912 commit 6bf696a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const load: LayoutLoad = async ({ depends, url }) => {
depends(Dependencies.ACCOUNT);

try {
const account = await sdk.forConsole.account.get();
const account = await sdk.forConsole.account.get<{ organization?: string }>();

LogRocket.identify(account.$id, {
name: account.name,
Expand Down
4 changes: 2 additions & 2 deletions src/routes/console/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';

export const load: PageLoad = async ({ parent }) => {
const { organizations } = await parent();
const { organizations, account } = await parent();
if (organizations.total) {
const teamId = localStorage.getItem('organization') ?? organizations.teams[0].$id;
const teamId = account.prefs.organization ?? organizations.teams[0].$id;
throw redirect(303, `${base}/console/organization-${teamId}`);
} else {
throw redirect(303, `${base}/console/onboarding`);
Expand Down
3 changes: 1 addition & 2 deletions src/routes/console/project-[project]/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export const load: LayoutLoad = async ({ params, depends }) => {

try {
const project = await sdk.forConsole.projects.get(params.project);
localStorage.setItem('project', project.$id);
localStorage.setItem('organization', project.teamId);
sdk.forConsole.account.updatePrefs({ organization: project.teamId });
preferences.loadTeamPrefs(project.teamId);

return {
Expand Down

4 comments on commit 6bf696a

@vercel
Copy link

@vercel vercel bot commented on 6bf696a Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

console-preview – ./

console-next.vercel.app
console-preview-appwrite.vercel.app
console-preview-git-main-appwrite.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 6bf696a Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 6bf696a Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

console-cloud – ./

console-cloud.vercel.app
console-cloud-git-main-appwrite.vercel.app
console-cloud-appwrite.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 6bf696a Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.