Try to fetch alias on AssigneeInput

This commit is contained in:
Sebastian Martinez
2024-12-09 16:24:14 +01:00
parent 3b0daefec4
commit 3109e1d231
3 changed files with 24 additions and 14 deletions
+18 -7
View File
@@ -1,7 +1,12 @@
<script lang="ts">
import type { Author } from "@bindings/cob/Author";
import { authorForNodeId, parseNodeId } from "@app/lib/utils";
import {
authorForNodeId,
parseNodeId,
publicKeyFromDid,
} from "@app/lib/utils";
import { invoke } from "@app/lib/invoke";
import Icon from "@app/components/Icon.svelte";
import NodeId from "@app/components/NodeId.svelte";
@@ -11,12 +16,12 @@
allowedToEdit: boolean;
assignees: Author[];
submitInProgress: boolean;
save: (updatedAssignees: string[]) => void;
save: (updatedAssignees: Author[]) => void;
}
const {
allowedToEdit = false,
assignees,
assignees = $bindable(),
submitInProgress = false,
save,
}: Props = $props();
@@ -64,11 +69,17 @@
}
});
function addAssignee() {
async function addAssignee() {
if (valid && assignee) {
updatedAssignees = [...updatedAssignees, { did: assignee }];
const alias = await invoke<string | null>("alias", {
nid: publicKeyFromDid(assignee),
});
updatedAssignees = [
...updatedAssignees,
{ did: assignee, alias: alias ?? undefined },
];
inputValue = "";
save($state.snapshot(updatedAssignees.map(x => x.did)));
save($state.snapshot(updatedAssignees));
showInput = false;
}
}
@@ -77,7 +88,7 @@
updatedAssignees = updatedAssignees.filter(
({ did }) => did !== assignee.did,
);
save($state.snapshot(updatedAssignees.map(x => x.did)));
save($state.snapshot(updatedAssignees));
showInput = false;
}
</script>
+4 -5
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import type { Author } from "@bindings/cob/Author";
import type { Config } from "@bindings/config/Config";
import type { Issue } from "@bindings/cob/issue/Issue";
import type { RepoInfo } from "@bindings/repo/RepoInfo";
@@ -41,7 +42,7 @@
const embeds: { name: string; content: string }[] = [];
let assignees: string[] = $state([]);
let assignees: Author[] = $state([]);
let labels: string[] = $state([]);
async function createIssue() {
@@ -51,7 +52,7 @@
title,
description,
labels: $state.snapshot(labels),
assignees: $state.snapshot(assignees),
assignees: $state.snapshot(assignees.map(a => a.did)),
embeds,
},
opts: { announce: $nodeRunning && $announce },
@@ -161,9 +162,7 @@
<div class="metadata-section" style:flex="1">
<AssigneeInput
allowedToEdit={true}
assignees={assignees.map(assignee => {
return { did: assignee };
})}
bind:assignees
submitInProgress={false}
save={newAssignees => {
assignees = newAssignees;
+2 -2
View File
@@ -103,7 +103,7 @@
}
}
async function saveAssignees(assignees: string[]) {
async function saveAssignees(assignees: Author[]) {
try {
assigneesSaveInProgress = true;
await invoke("edit_issue", {
@@ -111,7 +111,7 @@
cobId: issue.id,
action: {
type: "assign",
assignees,
assignees: assignees.map(a => a.did),
},
opts: { announce: $nodeRunning && $announce },
});