Browse Source

moved notifications to the top

master
silberengel 7 months ago
parent
commit
dab4995dcf
  1. 8
      src/lib/components/EventDetails.svelte
  2. 12
      src/lib/components/Notifications.svelte

8
src/lib/components/EventDetails.svelte

@ -401,6 +401,11 @@
</h2> </h2>
{/if} {/if}
<!-- Notifications (for profile events) -->
{#if event.kind === 0}
<Notifications {event} />
{/if}
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
{#if toNpub(event.pubkey)} {#if toNpub(event.pubkey)}
<span class="text-gray-600 dark:text-gray-400" <span class="text-gray-600 dark:text-gray-400"
@ -474,9 +479,6 @@
{profile} {profile}
identifiers={getIdentifiers(event, profile)} identifiers={getIdentifiers(event, profile)}
/> />
<!-- Notifications for own profile -->
<Notifications {event} />
{/if} {/if}
<!-- Tags Array --> <!-- Tags Array -->

12
src/lib/components/Notifications.svelte

@ -92,9 +92,7 @@
function getNeventUrl(event: NDKEvent): string { function getNeventUrl(event: NDKEvent): string {
const relays = getAvailableRelays(); const relays = getAvailableRelays();
const nevent = neventEncode(event, relays); return neventEncode(event, relays);
console.log('Generated nevent for event:', event.id, '→', nevent);
return nevent;
} }
function formatDate(timestamp: number): string { function formatDate(timestamp: number): string {
@ -605,7 +603,7 @@
</div> </div>
{/if} {/if}
<div class="divide-y divide-gray-200 dark:divide-gray-700"> <div class="divide-y divide-gray-200 dark:divide-gray-700">
{#each filteredMessages.slice(0, 20) as message} {#each filteredMessages.slice(0, 100) as message}
{@const authorProfile = authorProfiles.get(message.pubkey)} {@const authorProfile = authorProfiles.get(message.pubkey)}
{@const isFromUser = message.pubkey === $userStore.pubkey} {@const isFromUser = message.pubkey === $userStore.pubkey}
<div class="p-4 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors" data-event-id="{message.id}"> <div class="p-4 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors" data-event-id="{message.id}">
@ -772,7 +770,7 @@
{:else} {:else}
<div class="max-h-[72rem] overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-lg"> <div class="max-h-[72rem] overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-lg">
<div class="divide-y divide-gray-200 dark:divide-gray-700"> <div class="divide-y divide-gray-200 dark:divide-gray-700">
{#each notifications.slice(0, 10) as notification} {#each notifications.slice(0, 100) as notification}
{@const authorProfile = authorProfiles.get(notification.pubkey)} {@const authorProfile = authorProfiles.get(notification.pubkey)}
<div class="p-4 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> <div class="p-4 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors">
<div class="flex items-start gap-3"> <div class="flex items-start gap-3">
@ -837,9 +835,9 @@
{/each} {/each}
</div> </div>
{#if notifications.length > 10} {#if notifications.length > 100}
<div class="p-4 text-center text-sm text-gray-600 dark:text-gray-400 border-t border-gray-200 dark:border-gray-700"> <div class="p-4 text-center text-sm text-gray-600 dark:text-gray-400 border-t border-gray-200 dark:border-gray-700">
Showing 10 of {notifications.length} notifications {notificationMode === "to-me" ? "received" : "sent"}. Scroll to see more. Showing 100 of {notifications.length} notifications {notificationMode === "to-me" ? "received" : "sent"}. Scroll to see more.
</div> </div>
{/if} {/if}
</div> </div>

Loading…
Cancel
Save