Implement org profile fallback

When an org doesn't have its own profile, but its owner does,
we fallback on that profile.

This allows for "user" orgs, where a user keeps his projects
anchored under an org, but all profile information under the user.
This commit is contained in:
Alexis Sellier
2021-07-21 16:39:58 +02:00
parent 07d2cf48eb
commit 2928e2fe14
8 changed files with 82 additions and 33 deletions
+4 -6
View File
@@ -5,7 +5,7 @@
import Loading from '@app/Loading.svelte';
import Modal from '@app/Modal.svelte';
import Avatar from '@app/Avatar.svelte';
import { Profile } from '@app/profile';
import { Org } from '@app/base/orgs/Org';
import Browser from './Browser.svelte';
@@ -16,13 +16,11 @@
export let path: string;
let projectRoot = proj.path({ urn, org, commit });
let getProject = new Promise<string | undefined>(resolve => {
let getProject = new Promise<string | null>(resolve => {
if (org) {
Profile.get(org, config).then((p: Profile) => {
resolve(p.seed);
});
Org.getProfile(org, config).then(p => resolve(p?.seed || null));
} else {
resolve(undefined);
resolve(null);
}
}).then(async (seed) => {
const cfg = seed ? config.withSeed(seed) : config;
+1 -3
View File
@@ -16,15 +16,13 @@
export let project: proj.Project;
export let config: Config;
export let org: string | undefined;
export let seed: string | undefined;
let state: State = { status: Status.Loading };
let info: proj.Info | null = null;
onMount(async () => {
try {
const cfg = seed ? config.withSeed(seed) : config;
const result = await proj.getInfo(project.id, cfg);
const result = await proj.getInfo(project.id, config);
state = { status: Status.Loaded };
info = result;
} catch (err) {