mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +08:00
Convert cob actions into customized desktop actions
This commit allows us to e.g. convert the Set of DIDs we obtain from assignee actions on cobs into a Set of Authors with their Aliases. Also it introduces the `FromRadicleAction` trait which can be implemented for any type of enum we get from the `radicle` create to convert into a type which is better suited for us. Removes also any calling the `alias` command in the `PatchTimeline` or `IssueTimeline` since we already get the alias from the backend the first time now.
This commit is contained in:
@@ -18,11 +18,9 @@
|
||||
formatTimestamp,
|
||||
issueStatusColor,
|
||||
pluralize,
|
||||
publicKeyFromDid,
|
||||
} from "@app/lib/utils";
|
||||
import Icon from "./Icon.svelte";
|
||||
import NodeId from "./NodeId.svelte";
|
||||
import { invoke } from "@app/lib/invoke";
|
||||
import Id from "./Id.svelte";
|
||||
|
||||
interface Props {
|
||||
@@ -66,7 +64,7 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
function itemDiff(previousState: string[], newState: string[]) {
|
||||
function itemDiff<A>(previousState: A[], newState: A[]) {
|
||||
const removed = previousState.filter(x => !newState.includes(x));
|
||||
const added = newState.filter(x => !previousState.includes(x));
|
||||
return { removed, added };
|
||||
@@ -169,7 +167,7 @@
|
||||
<div class="wrapper">
|
||||
<NodeId {...authorForNodeId(op.author)} />
|
||||
{#if op.previous && op.previous.type === op.type}
|
||||
{@const changed = itemDiff(
|
||||
{@const changed = itemDiff<Author>(
|
||||
op.previous?.assignees ?? [],
|
||||
op.assignees,
|
||||
)}
|
||||
@@ -177,38 +175,20 @@
|
||||
{#if changed.added.length}
|
||||
assigned
|
||||
{#each changed.added as assignee}
|
||||
{#await invoke<string | null>( "alias", { nid: publicKeyFromDid(assignee) }, ) then alias}
|
||||
<NodeId
|
||||
{...authorForNodeId({
|
||||
did: assignee,
|
||||
alias: alias ?? undefined,
|
||||
})} />
|
||||
{/await}
|
||||
<NodeId {...authorForNodeId(assignee)} />
|
||||
{/each}
|
||||
{/if}
|
||||
{#if changed.removed.length}
|
||||
unassigned
|
||||
{#each changed.removed as assignee}
|
||||
{#await invoke<string | null>( "alias", { nid: publicKeyFromDid(assignee) }, ) then alias}
|
||||
<NodeId
|
||||
{...authorForNodeId({
|
||||
did: assignee,
|
||||
alias: alias ?? undefined,
|
||||
})} />
|
||||
{/await}
|
||||
<NodeId {...authorForNodeId(assignee)} />
|
||||
{/each}
|
||||
{/if}
|
||||
{/if}
|
||||
{:else}
|
||||
assigned
|
||||
{#each op.assignees as assignee}
|
||||
{#await invoke<string | null>( "alias", { nid: publicKeyFromDid(assignee) }, ) then alias}
|
||||
<NodeId
|
||||
{...authorForNodeId({
|
||||
did: assignee,
|
||||
alias: alias ?? undefined,
|
||||
})} />
|
||||
{/await}
|
||||
<NodeId {...authorForNodeId(assignee)} />
|
||||
{/each}
|
||||
{/if}
|
||||
<div title={absoluteTimestamp(op.timestamp)}>
|
||||
|
||||
@@ -18,12 +18,10 @@
|
||||
formatTimestamp,
|
||||
patchStatusColor,
|
||||
pluralize,
|
||||
publicKeyFromDid,
|
||||
} from "@app/lib/utils";
|
||||
import Icon from "./Icon.svelte";
|
||||
import Id from "./Id.svelte";
|
||||
import NodeId from "./NodeId.svelte";
|
||||
import { invoke } from "@app/lib/invoke";
|
||||
|
||||
interface Props {
|
||||
patchId: string;
|
||||
@@ -67,7 +65,7 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
function itemDiff(previousState: string[], newState: string[]) {
|
||||
function itemDiff<A>(previousState: A[], newState: A[]) {
|
||||
const removed = previousState.filter(x => !newState.includes(x));
|
||||
const added = newState.filter(x => !previousState.includes(x));
|
||||
return { removed, added };
|
||||
@@ -190,44 +188,26 @@
|
||||
<div class="wrapper">
|
||||
<NodeId {...authorForNodeId(op.author)} />
|
||||
{#if op.previous && op.previous.type === op.type}
|
||||
{@const changed = itemDiff(
|
||||
{@const changed = itemDiff<Author>(
|
||||
op.previous?.assignees ?? [],
|
||||
op.assignees,
|
||||
)}
|
||||
{#if changed.added.length}
|
||||
assigned
|
||||
{#each changed.added as assignee}
|
||||
{#await invoke<string | null>( "alias", { nid: publicKeyFromDid(assignee) }, ) then alias}
|
||||
<NodeId
|
||||
{...authorForNodeId({
|
||||
did: assignee,
|
||||
alias: alias ?? undefined,
|
||||
})} />
|
||||
{/await}
|
||||
<NodeId {...authorForNodeId(assignee)} />
|
||||
{/each}
|
||||
{/if}
|
||||
{#if changed.removed.length}
|
||||
unassigned
|
||||
{#each changed.removed as assignee}
|
||||
{#await invoke<string | null>( "alias", { nid: publicKeyFromDid(assignee) }, ) then alias}
|
||||
<NodeId
|
||||
{...authorForNodeId({
|
||||
did: assignee,
|
||||
alias: alias ?? undefined,
|
||||
})} />
|
||||
{/await}
|
||||
<NodeId {...authorForNodeId(assignee)} />
|
||||
{/each}
|
||||
{/if}
|
||||
{:else}
|
||||
assigned
|
||||
{#each op.assignees as assignee}
|
||||
{#await invoke<string | null>( "alias", { nid: publicKeyFromDid(assignee) }, ) then alias}
|
||||
<NodeId
|
||||
{...authorForNodeId({
|
||||
did: assignee,
|
||||
alias: alias ?? undefined,
|
||||
})} />
|
||||
{/await}
|
||||
<NodeId {...authorForNodeId(assignee)} />
|
||||
{/each}
|
||||
{/if}
|
||||
<div title={absoluteTimestamp(op.timestamp)}>
|
||||
|
||||
Reference in New Issue
Block a user