Skip to content

Commit

Permalink
Add zaps to reactions notifications, fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Staab committed Jan 23, 2025
1 parent d6c7a51 commit 507fea9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
14 changes: 9 additions & 5 deletions src/app/shared/NoteMeta.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import {uniq, spec, groupBy, pluck, uniqBy, prop} from "@welshman/lib"
import {uniq, identity, spec, groupBy, pluck, uniqBy, prop} from "@welshman/lib"
import type {TrustedEvent} from "@welshman/util"
import {REACTION, ZAP_RESPONSE} from "@welshman/util"
import {REACTION, ZAP_RESPONSE, getTagValue} from "@welshman/util"
import {repostKinds} from "src/util/nostr"
import Icon from "src/partials/Icon.svelte"
import PersonLink from "src/app/shared/PersonLink.svelte"
Expand All @@ -17,9 +17,9 @@
</script>

{#if zaps.length > 0}
{@const pubkeys = getPubkeys(zaps)}
{@const pubkeys = uniq(zaps.map(e => getTagValue("P", e.tags)).filter(identity))}
<p class="flex items-center gap-1 pb-2 text-sm text-neutral-300">
<i class="fa fa-rotate" />
<Icon icon="bolt" />
Zapped by
{#if pubkeys.length === 1}
<PersonLink pubkey={pubkeys[0]} />
Expand Down Expand Up @@ -53,7 +53,11 @@
{reactions.length} people reacted:
{#each groupBy(e => e.content, reactions) as [content, events] (content)}
<span class="flex items-center gap-1">
{content}
{#if content === "+"}
<Icon icon="heart" />
{:else}
{content}
{/if}
<PersonCircles class="h-5 w-5" pubkeys={getPubkeys(events)} />
</span>
{/each}
Expand Down
30 changes: 16 additions & 14 deletions src/app/shared/NotificationItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@
{/if}

<NoteReducer {events} depth={1} bind:items let:event let:getContext>
<div class="flex items-center justify-between">
{#if getContext(event).length === 0}
<PeopleAction pubkeys={[event.pubkey]} actionText="mentioned you" />
{:else if event.pubkey === $pubkey}
<PeopleAction
pubkeys={uniq(pluck("pubkey", getContext(event)))}
actionText="{verb} to your note" />
{:else}
<PeopleAction
pubkeys={uniq(pluck("pubkey", getContext(event)))}
actionText="{verb} to a note mentioning you" />
{/if}
<small>{formatTimestamp(max(pluck("created_at", [event, ...getContext(event)])))}</small>
<div>
<div class="flex items-center justify-between">
{#if getContext(event).length === 0}
<PeopleAction pubkeys={[event.pubkey]} actionText="mentioned you" />
{:else if event.pubkey === $pubkey}
<PeopleAction
pubkeys={uniq(pluck("pubkey", getContext(event)))}
actionText="{verb} to your note" />
{:else}
<PeopleAction
pubkeys={uniq(pluck("pubkey", getContext(event)))}
actionText="{verb} to a note mentioning you" />
{/if}
<small>{formatTimestamp(max(pluck("created_at", [event, ...getContext(event)])))}</small>
</div>
<FeedItem topLevel showLoading note={event} {depth} {getContext} />
</div>
<FeedItem topLevel showLoading note={event} {depth} {getContext} />
</NoteReducer>
3 changes: 1 addition & 2 deletions src/engine/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ export const reactionNotifications = derived(
e =>
e.pubkey !== $pubkey &&
e.tags.some(t => t[0] === "p" && t[1] === $pubkey) &&
!$isEventMuted(e) &&
isLike(e),
!$isEventMuted(e),
),
),
)
Expand Down

0 comments on commit 507fea9

Please sign in to comment.