Improve notifications messages

This commit is contained in:
dtonon 2026-09-23 12:31:49 +02:00
parent 982c20d1fa
commit 6cc1674279
2 changed files with 29 additions and 10 deletions

View file

@ -60,16 +60,17 @@
function verb(n: Notification): string {
switch (n.kind) {
case "quote":
case "reply-op":
return "replied to your discussion";
return "replied to you in";
case "reply":
return "replied in";
return "wrote in";
case "mention":
return "mentioned you in";
case "chat-reply":
return "replied to you in chat";
case "chat-mention":
return "mentioned you in chat";
return MODE === "full" ? "mentioned you in" : "mentioned you in chat";
}
}
@ -157,6 +158,14 @@
<span class="group-hover:text-accent">
{n.title || "a discussion"}
</span>
{:else if n.kind === "chat-mention" && MODE === "full"}
<span class="group-hover:text-accent"
>{getGroupName(n.groupId)}</span
>
<span
class="font-normal text-neutral-500 dark:text-neutral-400"
>chat</span
>
{/if}
</p>
{#if text}

View file

@ -3,12 +3,19 @@ import { extractMentionPubkeys } from "$lib/mentions";
import { tag, type Query } from "./query";
export type NotificationKind =
| "reply-op" // reply to a discussion the user started
| "reply" // reply in a discussion the user took part in
| "quote" // reply quoting one of the user's posts
| "mention" // mentioned in a discussion reply
| "reply-op" // reply to a discussion the user started
| "reply" // reply in a discussion the user took part in, p-tag only
| "chat-reply" // chat reply to the user's message
| "chat-mention"; // mentioned in chat
// Everything but plain thread activity is addressed to the user. Not applied
// yet: a future setting will let users leave plain activity out of the badge.
export function isDirect(kind: NotificationKind): boolean {
return kind !== "reply";
}
export type Notification = {
id: string;
kind: NotificationKind;
@ -43,7 +50,10 @@ export function parseNotification(e: Event, me: string): Notification | null {
if (e.kind === 1111) {
const threadId = tag(e, "E");
if (!threadId) return null;
const kind: NotificationKind = mentioned
const quoted = e.tags.some((t) => t[0] === "q" && t[3] === me);
const kind: NotificationKind = quoted
? "quote"
: mentioned
? "mention"
: tag(e, "P") === me
? "reply-op"