mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
desktop: Refresh the identity view
Proposals and votes show as they arrive. Identity COB updates now refresh only the identity instead of the whole repository.
This commit is contained in:
@@ -6,6 +6,8 @@ export type Key = readonly string[];
|
||||
export const keys = {
|
||||
repo: (rid: string) => ["repo", rid] as const,
|
||||
repoInfo: (rid: string) => ["repo", rid, "info"] as const,
|
||||
// The identity document's revisions and proposals.
|
||||
identity: (rid: string) => ["repo", rid, "identity"] as const,
|
||||
code: (rid: string) => ["repo", rid, "code"] as const,
|
||||
// The commit a revision resolves to; no revision means the default branch.
|
||||
head: (rid: string, peer: string | undefined, revision: string | undefined) =>
|
||||
|
||||
@@ -17,6 +17,7 @@ export const cobTypes = {
|
||||
// Releases are artifact COBs.
|
||||
release: "dev.radicle.artifact",
|
||||
board: "works.monadic.board",
|
||||
identity: "xyz.radicle.id",
|
||||
} as const;
|
||||
const {
|
||||
issue: ISSUE,
|
||||
@@ -24,6 +25,7 @@ const {
|
||||
job: JOB,
|
||||
release: RELEASE,
|
||||
board: BOARD,
|
||||
identity: IDENTITY,
|
||||
} = cobTypes;
|
||||
|
||||
export function affectedKeys({ rid, refs }: RefUpdate): Key[] {
|
||||
@@ -54,6 +56,10 @@ export function affectedKeys({ rid, refs }: RefUpdate): Key[] {
|
||||
add(keys.releases(rid));
|
||||
} else if (cob && cob[1] === BOARD) {
|
||||
add(keys.boards(rid));
|
||||
} else if (cob && cob[1] === IDENTITY) {
|
||||
// Proposals and votes. An accepted revision also moves `refs/rad/id`,
|
||||
// which affects the whole repository.
|
||||
add(keys.identity(rid));
|
||||
} else if (/^refs\/(heads|tags)\//.test(name)) {
|
||||
add(keys.code(rid));
|
||||
add(keys.repoInfo(rid));
|
||||
|
||||
@@ -86,4 +86,13 @@ describe("affectedKeys", () => {
|
||||
}),
|
||||
).toEqual([keys.repo(rid)]);
|
||||
});
|
||||
|
||||
test("identity proposals affect only the identity", () => {
|
||||
expect(
|
||||
affectedKeys({
|
||||
rid,
|
||||
refs: [`refs/namespaces/${nid}/refs/cobs/xyz.radicle.id/${issue}`],
|
||||
}),
|
||||
).toEqual([keys.identity(rid)]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user