Narrow down IssueOp type by flattening it

This commit is contained in:
Sebastian Martinez
2024-10-22 12:29:35 +02:00
committed by Rūdolfs Ošiņš
parent 5ed10a408c
commit caebd0a325
4 changed files with 79 additions and 40 deletions
+13 -14
View File
@@ -2,7 +2,7 @@
import type { Config } from "@bindings/Config";
import type { Issue } from "@bindings/Issue";
import type { RepoInfo } from "@bindings/RepoInfo";
import type { IssueOps } from "@bindings/IssueOps";
import type { IssueOp } from "@bindings/IssueOp";
import capitalize from "lodash/capitalize";
@@ -221,32 +221,31 @@
{/if}
</div>
<div>
{#await invoke<IssueOps[]>( "activity_by_id", { rid: repo.rid, typeName: "xyz.radicle.issue", id: issue.id }, ) then activity}
{#each activity.slice(1) as { action, timestamp, author }}
{#if action.type === "lifecycle"}
{#await invoke<IssueOp[]>( "activity_by_id", { rid: repo.rid, typeName: "xyz.radicle.issue", id: issue.id }, ) then activity}
{#each activity.slice(1) as op}
{#if op.type === "lifecycle"}
<div class="txt-small body">
<div class="global-flex txt-small">
<NodeId {...authorForNodeId(author)} />
alias={author.alias} /> change of status to {action.state
.status}
<NodeId {...authorForNodeId(op.author)} />
alias={op.author.alias} /> change of status to {op.state.status}
<!-- <div class="global-oid"></div> -->
{formatTimestamp(timestamp)}
{formatTimestamp(op.timestamp)}
</div>
</div>
{:else if action.type === "comment"}
{:else if op.type === "comment"}
<div class="txt-small body">
<Markdown rid={repo.rid} breaks content={action.body} />
<Markdown rid={repo.rid} breaks content={op.body} />
<div class="global-flex txt-small" style:margin-top="1.5rem">
<NodeId {...authorForNodeId(author)} />
{#if action.replyTo}
<NodeId {...authorForNodeId(op.author)} />
{#if op.replyTo}
replied to <div class="global-oid">
{formatOid(action.replyTo)}
{formatOid(op.replyTo)}
</div>
{:else}
commented
{/if}
<!-- <div class="global-oid"></div> -->
{formatTimestamp(timestamp)}
{formatTimestamp(op.timestamp)}
</div>
</div>
{/if}