Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add embeds also to revisions
Sebastian Martinez committed 2 years ago
commit 87afc6204c0a89ebeae34304102f7cd51441c48b
parent cc08490eebbe9f86ec17b9f82cafb1174840339a
3 files changed +27 -13
modified src/views/projects/Cob/Revision.svelte
@@ -4,6 +4,7 @@
    DiffResponse,
    Embed,
    PatchState,
+
    Revision,
    Verdict,
  } from "@httpd-client";
  import type { Timeline } from "@app/views/projects/Patch.svelte";
@@ -11,6 +12,7 @@
  import * as utils from "@app/lib/utils";
  import { HttpdClient } from "@httpd-client";
  import { onMount } from "svelte";
+
  import { parseEmbedIntoMap } from "@app/lib/file";

  import CobCommitTeaser from "@app/views/projects/Cob/CobCommitTeaser.svelte";
  import CommentComponent from "@app/components/Comment.svelte";
@@ -39,6 +41,7 @@
  export let projectId: string;
  export let revisionBase: string;
  export let revisionId: string;
+
  export let revisionEdits: Revision["edits"];
  export let revisionOid: string;
  export let revisionTimestamp: number;
  export let revisionAuthor: { id: string; alias?: string | undefined };
@@ -62,6 +65,7 @@
    | undefined;

  const api = new HttpdClient(baseUrl);
+
  const latestEdit = revisionEdits.pop();

  function formatVerdict(verdict?: Verdict | null) {
    switch (verdict) {
@@ -399,9 +403,11 @@
              </div>
            </div>
          </div>
-
          {#if editRevision && revisionState !== "read"}
+
          {#if editRevision && latestEdit && revisionState !== "read"}
            {@const editRevision_ = editRevision}
            <ExtendedTextarea
+
              enableAttachments
+
              embeds={parseEmbedIntoMap(latestEdit.embeds)}
              rawPath={rawPath(revisionId)}
              body={revisionDescription}
              submitCaption="Save"
modified src/views/projects/Patch.svelte
@@ -6,6 +6,7 @@
    Project,
    LifecycleState,
    PatchState,
+
    Revision,
  } from "@httpd-client";

  interface Thread {
@@ -91,6 +92,7 @@
    ["Archive patch", { status: "archived" }],
    ["Convert to draft", { status: "draft" }],
  ];
+
  const latestEdit = patch.revisions[0].edits.pop();

  async function editPatch(sessionId: string, title: string) {
    try {
@@ -506,6 +508,7 @@
        revisionTimestamp: number;
        revisionBase: string;
        revisionOid: string;
+
        revisionEdits: Revision["edits"];
        revisionAuthor: { id: string; alias?: string | undefined };
        revisionDescription: string;
      },
@@ -517,6 +520,7 @@
      revisionTimestamp: rev.timestamp,
      revisionBase: rev.base,
      revisionOid: rev.oid,
+
      revisionEdits: rev.edits,
      revisionAuthor: rev.author,
      revisionDescription: rev.description,
    },
@@ -694,29 +698,33 @@
        </svelte:fragment>
        <svelte:fragment slot="description">
          <div class="revision-description">
-
            {#if session && patchState !== "read"}
-
              {@const latestEdit = patch.revisions[0].edits.pop()}
+
            {#if session && patchState !== "read" && latestEdit}
              <ExtendedTextarea
                validateBody={false}
                enableAttachments
-
                embeds={latestEdit && parseEmbedIntoMap(latestEdit.embeds)}
+
                embeds={parseEmbedIntoMap(latestEdit.embeds)}
                rawPath={rawPath(patch.revisions[0].id)}
                body={newDescription}
                submitCaption="Save"
                submitInProgress={patchState === "submit"}
                placeholder="Leave a description"
-
                on:close={() => (patchState = "read")}
+
                on:close={() => {
+
                  patchState = "read";
+
                  void refreshPatch();
+
                }}
                on:submit={async ({ detail: { comment, embeds } }) => {
                  patchState = "submit";
                  if (session) {
                    try {
-
                      await editPatch(session.id, patch.title);
-
                      await editRevision(
-
                        session.id,
-
                        patch.id,
-
                        comment,
-
                        Array.from(embeds.values()),
-
                      );
+
                      await Promise.all([
+
                        editPatch(session.id, patch.title),
+
                        editRevision(
+
                          session.id,
+
                          patch.id,
+
                          comment,
+
                          Array.from(embeds.values()),
+
                        ),
+
                      ]);
                    } finally {
                      patchState = "read";
                    }
modified tests/support/heartwood-version
@@ -1 +1 @@
-
59f506dbb5591d3fe68e638038495730c455d72a
+
6bc7d297a5e7e3feecec3f61327a9adbdf532f61

\ No newline at end of file