Radish alpha
r
Radicle desktop app
Radicle
Git (anonymous pull)
Log in to clone via SSH
Try to fetch alias on AssigneeInput
Sebastian Martinez committed 1 year ago
commit 3109e1d231e0a09cc9064a8e40341f54adea906a
parent 3b0daefec4d5932ed17e3b466ee38c80fd5dcdc0
3 files changed +24 -14
modified src/components/AssigneeInput.svelte
@@ -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>
modified src/views/repo/CreateIssue.svelte
@@ -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;
modified src/views/repo/Issue.svelte
@@ -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 },
      });