Notifications: fix Favourites and EmojiReacts not being displayed
This commit is contained in:
parent
e25372313b
commit
0a3be0da58
|
@ -76,6 +76,13 @@ function assembleEvents(
|
|||
}
|
||||
}
|
||||
|
||||
if (event.kind === 7) {
|
||||
const id = event.tags.find(([name]) => name === 'e')?.[1];
|
||||
if (id) {
|
||||
event.reacted = b.find((e) => matchFilter({ kinds: [1], ids: [id] }, e));
|
||||
}
|
||||
}
|
||||
|
||||
if (event.kind === 1) {
|
||||
const id = event.tags.find(([name]) => name === 'q')?.[1];
|
||||
if (id) {
|
||||
|
|
|
@ -2,6 +2,7 @@ import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
|||
import { nostrDate } from '@/utils.ts';
|
||||
import { accountFromPubkey, renderAccount } from '@/views/mastodon/accounts.ts';
|
||||
import { renderStatus } from '@/views/mastodon/statuses.ts';
|
||||
import { NostrEvent } from '@nostrify/nostrify';
|
||||
|
||||
interface RenderNotificationOpts {
|
||||
viewerPubkey: string;
|
||||
|
@ -32,7 +33,7 @@ async function renderMention(event: DittoEvent, opts: RenderNotificationOpts) {
|
|||
if (!status) return;
|
||||
|
||||
return {
|
||||
id: event.id,
|
||||
id: notificationId(event),
|
||||
type: 'mention',
|
||||
created_at: nostrDate(event.created_at).toISOString(),
|
||||
account: status.account,
|
||||
|
@ -47,7 +48,7 @@ async function renderReblog(event: DittoEvent, opts: RenderNotificationOpts) {
|
|||
const account = event.author ? await renderAccount(event.author) : accountFromPubkey(event.pubkey);
|
||||
|
||||
return {
|
||||
id: event.id,
|
||||
id: notificationId(event),
|
||||
type: 'reblog',
|
||||
created_at: nostrDate(event.created_at).toISOString(),
|
||||
account,
|
||||
|
@ -62,7 +63,7 @@ async function renderFavourite(event: DittoEvent, opts: RenderNotificationOpts)
|
|||
const account = event.author ? await renderAccount(event.author) : accountFromPubkey(event.pubkey);
|
||||
|
||||
return {
|
||||
id: event.id,
|
||||
id: notificationId(event),
|
||||
type: 'favourite',
|
||||
created_at: nostrDate(event.created_at).toISOString(),
|
||||
account,
|
||||
|
@ -77,7 +78,7 @@ async function renderReaction(event: DittoEvent, opts: RenderNotificationOpts) {
|
|||
const account = event.author ? await renderAccount(event.author) : accountFromPubkey(event.pubkey);
|
||||
|
||||
return {
|
||||
id: event.id,
|
||||
id: notificationId(event),
|
||||
type: 'pleroma:emoji_reaction',
|
||||
emoji: event.content,
|
||||
created_at: nostrDate(event.created_at).toISOString(),
|
||||
|
@ -86,4 +87,9 @@ async function renderReaction(event: DittoEvent, opts: RenderNotificationOpts) {
|
|||
};
|
||||
}
|
||||
|
||||
/** This helps notifications be sorted in the correct order. */
|
||||
function notificationId({ id, created_at }: NostrEvent): string {
|
||||
return `${created_at}-${id}`;
|
||||
}
|
||||
|
||||
export { renderNotification };
|
||||
|
|
Loading…
Reference in New Issue