Query delegate projects if radicle.id is set

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier
2022-02-10 13:23:41 +01:00
parent 4651275e71
commit 217bd814a6
5 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -59,7 +59,7 @@
</style>
<div class="projects">
{#await seed.getProjects()}
{#await seed.getProjects(profile?.id)}
<Loading center />
{:then projects}
{#each projects as project}
+4 -1
View File
@@ -17,6 +17,7 @@ export interface Registration {
export interface EnsProfile {
name: string;
id?: string;
owner?: string;
address?: string;
seed?: Seed | InvalidSeed;
@@ -73,6 +74,7 @@ export async function getRegistration(name: string, config: Config, resolver?: E
resolver.getAddress(),
resolver.getText('avatar'),
resolver.getText('url'),
resolver.getText('eth.radicle.id'),
resolver.getText('eth.radicle.seed.id'),
resolver.getText('eth.radicle.seed.host'),
resolver.getText('eth.radicle.seed.git'),
@@ -82,11 +84,12 @@ export async function getRegistration(name: string, config: Config, resolver?: E
resolver.getText('com.github'),
]);
const [address, avatar, url, seedId, seedHost, seedGit, seedApi, anchorsAccount, twitter, github] =
const [address, avatar, url, id, seedId, seedHost, seedGit, seedApi, anchorsAccount, twitter, github] =
meta.map(r => r.status == "fulfilled" && r.value ? r.value : undefined);
const profile: EnsProfile = {
name,
id,
url,
avatar,
anchorsAccount,
+5 -2
View File
@@ -68,8 +68,11 @@ export class Seed {
return proj.getInfo(urn, this.api);
}
async getProjects(): Promise<proj.ProjectInfo[]> {
const result = await proj.getProjects(this.api);
async getProjects(id?: string): Promise<proj.ProjectInfo[]> {
const result = id
? await proj.getDelegateProjects(id, this.api)
: await proj.getProjects(this.api);
return result.map((project: any) => ({ ...project, id: project.urn }));
}
+5
View File
@@ -37,6 +37,11 @@ export class Profile {
return this.profile.ens?.address ?? this.profile.address;
}
// Get radicle link id.
get id(): string | undefined {
return this.profile.ens?.id;
}
// Get the address type
get type(): AddressType {
return this.profile.type;
+4
View File
@@ -117,6 +117,10 @@ export async function getProjects(host: api.Host): Promise<ProjectInfo[]> {
return api.get("projects", {}, host);
}
export async function getDelegateProjects(delegate: string, host: api.Host): Promise<ProjectInfo[]> {
return api.get(`delegates/${delegate}/projects`, {}, host);
}
export async function getBranchesByPeer(urn: string, peer: string, host: api.Host): Promise<Branches> {
return api.get(`projects/${urn}/remotes/${peer}`, {}, host);
}