From 1da3f6ba0d95b50276ff868ccc887171816265d8 Mon Sep 17 00:00:00 2001 From: silberengel Date: Wed, 6 Aug 2025 23:50:09 +0200 Subject: [PATCH] Worked on the notifications some more --- src/lib/components/EventDetails.svelte | 2 +- src/lib/components/Notifications.svelte | 687 ++++++++++++++---------- 2 files changed, 397 insertions(+), 292 deletions(-) diff --git a/src/lib/components/EventDetails.svelte b/src/lib/components/EventDetails.svelte index 3a8801e..dcdd0eb 100644 --- a/src/lib/components/EventDetails.svelte +++ b/src/lib/components/EventDetails.svelte @@ -454,7 +454,7 @@
Content: -
+
{@html showFullContent ? parsedContent : contentPreview} {#if !showFullContent && parsedContent.length > 250} - + +
+ {#each ["to-me", "from-me", "public-messages"] as mode} + {@const modeLabel = mode === "to-me" ? "To Me" : mode === "from-me" ? "From Me" : "Public Messages"} + + {/each}
{#if loading}
- Loading notifications... + + Loading {notificationMode === "public-messages" ? "public messages" : "notifications"}... +
{:else if error}
-

Error loading notifications: {error}

-
- {:else if notifications.length === 0} -
-

No notifications {notificationMode === "to-me" ? "received" : "sent"} found.

+

Error loading {notificationMode === "public-messages" ? "public messages" : "notifications"}: {error}

- {:else} -
-
- {#each notifications.slice(0, 10) as notification} - {@const authorProfile = authorProfiles.get(notification.pubkey)} -
-
- -
- {#if authorProfile?.picture} - Author avatar { - (e.target as HTMLImageElement).style.display = 'none'; - }} - /> - {:else} -
- - {(authorProfile?.displayName || authorProfile?.name || notification.pubkey.slice(0, 1)).toUpperCase()} + {:else if notificationMode === "public-messages"} + {#if publicMessages.length === 0} +
+

No public messages found.

+
+ {:else} +
+ {#if filteredByUser} +
+
+ + Filtered by user: {authorProfiles.get(filteredByUser)?.displayName || authorProfiles.get(filteredByUser)?.name || `${filteredByUser.slice(0, 8)}...${filteredByUser.slice(-4)}`} + + +
+
+ {/if} +
+ {#each filteredMessages.slice(0, 20) as message} + {@const authorProfile = authorProfiles.get(message.pubkey)} + {@const isFromUser = message.pubkey === $userStore.pubkey} +
+
+ +
+ {#if authorProfile?.picture} + Author avatar (e.target as HTMLImageElement).style.display = 'none'} + /> + {:else} +
+ + {(authorProfile?.displayName || authorProfile?.name || message.pubkey.slice(0, 1)).toUpperCase()} + +
+ {/if} + + + {#if !isFromUser} +
+ +
+ {/if} +
+ + +
+
+ + {isFromUser ? 'Your Message' : 'Public Message'} + + + {message.created_at ? formatDate(message.created_at) : "Unknown date"} + +
+ + +
+ + {authorProfile?.displayName || authorProfile?.name || `${message.pubkey.slice(0, 8)}...${message.pubkey.slice(-4)}`} + {#if authorProfile?.name && authorProfile?.displayName && authorProfile.name !== authorProfile.displayName} + + (@{authorProfile.name}) + + {/if}
- {/if} + + {#if message.content} +
+ {truncateContent(message.content)} +
+ {/if} + +
+ + + {getNeventUrl(message).slice(0, 16)}... + +
+
- - -
-
- - {getNotificationType(notification)} - - - {notification.created_at ? formatDate(notification.created_at) : "Unknown date"} - +
+ {/each} +
+ + {#if filteredMessages.length > 20} +
+ Showing 20 of {filteredMessages.length} messages {filteredByUser ? `(filtered)` : ''}. Scroll to see more. +
+ {/if} +
+ {/if} + {:else} + {#if notifications.length === 0} +
+

No notifications {notificationMode === "to-me" ? "received" : "sent"} found.

+
+ {:else} +
+
+ {#each notifications.slice(0, 10) as notification} + {@const authorProfile = authorProfiles.get(notification.pubkey)} +
+
+ +
+ {#if authorProfile?.picture} + Author avatar (e.target as HTMLImageElement).style.display = 'none'} + /> + {:else} +
+ + {(authorProfile?.displayName || authorProfile?.name || notification.pubkey.slice(0, 1)).toUpperCase()} + +
+ {/if}
- -
- - {authorProfile?.displayName || authorProfile?.name || `${notification.pubkey.slice(0, 8)}...${notification.pubkey.slice(-4)}`} - - {#if authorProfile?.name && authorProfile?.displayName && authorProfile.name !== authorProfile.displayName} - - (@{authorProfile.name}) + +
+
+ + {getNotificationType(notification)} + + {notification.created_at ? formatDate(notification.created_at) : "Unknown date"} + +
+ + +
+ + {authorProfile?.displayName || authorProfile?.name || `${notification.pubkey.slice(0, 8)}...${notification.pubkey.slice(-4)}`} + + {#if authorProfile?.name && authorProfile?.displayName && authorProfile.name !== authorProfile.displayName} + + (@{authorProfile.name}) + + {/if} +
+ + {#if notification.content} +
+ {truncateContent(notification.content)} +
{/if} -
- - {#if notification.content} -
- {truncateContent(notification.content)} + +
+ + + {getNeventUrl(notification).slice(0, 16)}... +
- {/if} - -
- - - {getNeventUrl(notification).slice(0, 16)}... -
+ {/each} +
+ + {#if notifications.length > 10} +
+ Showing 10 of {notifications.length} notifications {notificationMode === "to-me" ? "received" : "sent"}. Scroll to see more.
- {/each} + {/if}
- - {#if notifications.length > 10} -
- Showing 10 of {notifications.length} notifications {notificationMode === "to-me" ? "received" : "sent"}. Scroll to see more. -
- {/if} -
+ {/if} {/if}
{/if} \ No newline at end of file