Add embeds to patches

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez
2023-10-26 16:58:14 +02:00
parent 5e5f7fc12f
commit c1740beb12
4 changed files with 36 additions and 20 deletions
+7 -4
View File
@@ -1,4 +1,6 @@
<script lang="ts" strictEvents>
import type { Embed } from "@app/lib/file";
import { createEventDispatcher, tick } from "svelte";
import { authenticated } from "@app/lib/httpd";
@@ -16,6 +18,7 @@
export let authorId: string;
export let authorAlias: string | undefined = undefined;
export let body: string;
export let enableAttachments: boolean = false;
export let reactions: [string, string][];
export let caption = "commented";
export let rawPath: string;
@@ -29,7 +32,7 @@
const dispatch = createEventDispatcher<{
react: { nids: string[]; id: string; reaction: string };
edit: string;
edit: { comment: string; embeds: Embed[] };
}>();
$: groupedReactions = reactions?.reduce(
@@ -144,12 +147,12 @@
{#if editInProgress}
<ExtendedTextarea
{body}
enableAttachments
{enableAttachments}
submitCaption="Save"
placeholder="Leave your description"
on:submit={({ detail: { comment } }) => {
on:submit={({ detail: { comment, embeds } }) => {
editInProgress = false;
dispatch("edit", comment);
dispatch("edit", { comment, embeds });
}}
on:close={async () => {
body = body;
+15 -6
View File
@@ -1,5 +1,6 @@
<script lang="ts" strictEvents>
import type { Comment } from "@httpd-client";
import type { Embed } from "@app/lib/file";
import { createEventDispatcher, tick } from "svelte";
import { httpdStore } from "@app/lib/httpd";
@@ -25,10 +26,10 @@
const dispatch = createEventDispatcher<{
reply: {
id: string;
embeds: { name: string; content: string }[];
embeds: Embed[];
body: string;
};
editComment: { id: string; body: string };
editComment: { id: string; body: string; embeds: Embed[] };
react: { nids: string[]; commentId: string | undefined; reaction: string };
cancel: never;
}>();
@@ -73,8 +74,12 @@
timestamp={root.timestamp}
disableEdit={root.embeds.length > 0}
body={root.body}
on:edit={event =>
dispatch("editComment", { id: root.id, body: event.detail })}
on:edit={({ detail }) =>
dispatch("editComment", {
id: root.id,
body: detail.comment,
embeds: detail.embeds,
})}
on:react>
<IconSmall name="chat" slot="icon" />
</CommentComponent>
@@ -94,8 +99,12 @@
timestamp={reply.timestamp}
disableEdit={reply.embeds.length > 0}
body={reply.body}
on:edit={event =>
dispatch("editComment", { id: reply.id, body: event.detail })}
on:edit={({ detail }) =>
dispatch("editComment", {
id: reply.id,
body: detail.comment,
embeds: detail.embeds,
})}
on:react />
{/each}
</div>