From d66371d5735c8ee69eb890c43a2b5a6e33c69b9a Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Thu, 6 Feb 2025 09:39:23 -0800 Subject: [PATCH] Break out a few shared sub-components --- .../components/CalendarEventActions.svelte | 15 ++++----------- src/app/components/CalendarEventItem.svelte | 17 +++-------------- src/app/components/EventPostedBy.svelte | 19 +++++++++++++++++++ src/app/components/ThreadActions.svelte | 14 ++++---------- src/app/components/ThreadItem.svelte | 14 ++------------ .../components/ThunkStatusOrDeleted.svelte | 17 +++++++++++++++++ 6 files changed, 49 insertions(+), 47 deletions(-) create mode 100644 src/app/components/EventPostedBy.svelte create mode 100644 src/app/components/ThunkStatusOrDeleted.svelte diff --git a/src/app/components/CalendarEventActions.svelte b/src/app/components/CalendarEventActions.svelte index 56cbeac..b5706a4 100644 --- a/src/app/components/CalendarEventActions.svelte +++ b/src/app/components/CalendarEventActions.svelte @@ -3,16 +3,16 @@ import {type Instance} from "tippy.js" import type {NativeEmoji} from "emoji-picker-element/shared" import {max} from "@welshman/lib" - import {deriveEvents, deriveIsDeleted} from "@welshman/store" + import {deriveEvents} from "@welshman/store" import type {TrustedEvent} from "@welshman/util" import {COMMENT} from "@welshman/util" - import {thunks, load, pubkey, repository, formatTimestampRelative} from "@welshman/app" + import {load, pubkey, repository, formatTimestampRelative} from "@welshman/app" import Icon from "@lib/components/Icon.svelte" import Tippy from "@lib/components/Tippy.svelte" import Button from "@lib/components/Button.svelte" import EmojiButton from "@lib/components/EmojiButton.svelte" import ReactionSummary from "@app/components/ReactionSummary.svelte" - import ThunkStatus from "@app/components/ThunkStatus.svelte" + import ThunkStatusOrDeleted from "@app/components/ThunkStatusOrDeleted.svelte" import CalendarEventMenu from "@app/components/CalendarEventMenu.svelte" import {publishDelete, publishReaction} from "@app/commands" import {notifications} from "@app/notifications" @@ -25,9 +25,6 @@ } const {url, event, showActivity = false}: Props = $props() - - const thunk = $derived($thunks[event.id]) - const deleted = deriveIsDeleted(repository, event) const path = makeCalendarPath(url, event.id) const filters = [{kinds: [COMMENT], "#E": [event.id]}] const replies = deriveEvents(repository, {filters}) @@ -61,11 +58,7 @@
- {#if $deleted} -
Deleted
- {:else if thunk} - - {/if} + {#if showActivity}
diff --git a/src/app/components/CalendarEventItem.svelte b/src/app/components/CalendarEventItem.svelte index 03a29dd..b23252a 100644 --- a/src/app/components/CalendarEventItem.svelte +++ b/src/app/components/CalendarEventItem.svelte @@ -1,16 +1,12 @@ @@ -34,14 +28,9 @@ : formatTimestamp(end)}
- +
- - Posted by - - +
diff --git a/src/app/components/EventPostedBy.svelte b/src/app/components/EventPostedBy.svelte new file mode 100644 index 0000000..a2187fa --- /dev/null +++ b/src/app/components/EventPostedBy.svelte @@ -0,0 +1,19 @@ + + + + Posted by + + diff --git a/src/app/components/ThreadActions.svelte b/src/app/components/ThreadActions.svelte index 250ec67..eeb7525 100644 --- a/src/app/components/ThreadActions.svelte +++ b/src/app/components/ThreadActions.svelte @@ -3,16 +3,16 @@ import {type Instance} from "tippy.js" import type {NativeEmoji} from "emoji-picker-element/shared" import {max} from "@welshman/lib" - import {deriveEvents, deriveIsDeleted} from "@welshman/store" + import {deriveEvents} from "@welshman/store" import type {TrustedEvent} from "@welshman/util" import {COMMENT} from "@welshman/util" - import {thunks, load, pubkey, repository, formatTimestampRelative} from "@welshman/app" + import {load, pubkey, repository, formatTimestampRelative} from "@welshman/app" import Icon from "@lib/components/Icon.svelte" import Tippy from "@lib/components/Tippy.svelte" import Button from "@lib/components/Button.svelte" import EmojiButton from "@lib/components/EmojiButton.svelte" import ReactionSummary from "@app/components/ReactionSummary.svelte" - import ThunkStatus from "@app/components/ThunkStatus.svelte" + import ThunkStatusOrDeleted from "@app/components/ThunkStatusOrDeleted.svelte" import ThreadMenu from "@app/components/ThreadMenu.svelte" import {publishDelete, publishReaction} from "@app/commands" import {notifications} from "@app/notifications" @@ -26,8 +26,6 @@ const {url, event, showActivity = false}: Props = $props() - const thunk = $derived($thunks[event.id]) - const deleted = deriveIsDeleted(repository, event) const path = makeThreadPath(url, event.id) const filters = [{kinds: [COMMENT], "#E": [event.id]}] const replies = deriveEvents(repository, {filters}) @@ -61,11 +59,7 @@
- {#if $deleted} -
Deleted
- {:else if thunk} - - {/if} + {#if showActivity}
diff --git a/src/app/components/ThreadItem.svelte b/src/app/components/ThreadItem.svelte index 1c7b455..ea10e8a 100644 --- a/src/app/components/ThreadItem.svelte +++ b/src/app/components/ThreadItem.svelte @@ -1,14 +1,11 @@ @@ -38,12 +33,7 @@ {/if}
- - Posted by - - + {#if !hideActions} {/if} diff --git a/src/app/components/ThunkStatusOrDeleted.svelte b/src/app/components/ThunkStatusOrDeleted.svelte new file mode 100644 index 0000000..c27b7e1 --- /dev/null +++ b/src/app/components/ThunkStatusOrDeleted.svelte @@ -0,0 +1,17 @@ + + +{#if $deleted} +
Deleted
+{:else if thunk} + +{/if}