mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 03:40:37 +08:00
Query delegate projects if radicle.id is set
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
@@ -59,7 +59,7 @@
|
||||
</style>
|
||||
|
||||
<div class="projects">
|
||||
{#await seed.getProjects()}
|
||||
{#await seed.getProjects(profile?.id)}
|
||||
<Loading center />
|
||||
{:then projects}
|
||||
{#each projects as project}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 }));
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user