Improve notifications messages
This commit is contained in:
parent
982c20d1fa
commit
6cc1674279
2 changed files with 29 additions and 10 deletions
|
|
@ -60,16 +60,17 @@
|
||||||
|
|
||||||
function verb(n: Notification): string {
|
function verb(n: Notification): string {
|
||||||
switch (n.kind) {
|
switch (n.kind) {
|
||||||
|
case "quote":
|
||||||
case "reply-op":
|
case "reply-op":
|
||||||
return "replied to your discussion";
|
return "replied to you in";
|
||||||
case "reply":
|
case "reply":
|
||||||
return "replied in";
|
return "wrote in";
|
||||||
case "mention":
|
case "mention":
|
||||||
return "mentioned you in";
|
return "mentioned you in";
|
||||||
case "chat-reply":
|
case "chat-reply":
|
||||||
return "replied to you in chat";
|
return "replied to you in chat";
|
||||||
case "chat-mention":
|
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">
|
<span class="group-hover:text-accent">
|
||||||
{n.title || "a discussion"}
|
{n.title || "a discussion"}
|
||||||
</span>
|
</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}
|
{/if}
|
||||||
</p>
|
</p>
|
||||||
{#if text}
|
{#if text}
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,19 @@ import { extractMentionPubkeys } from "$lib/mentions";
|
||||||
import { tag, type Query } from "./query";
|
import { tag, type Query } from "./query";
|
||||||
|
|
||||||
export type NotificationKind =
|
export type NotificationKind =
|
||||||
| "reply-op" // reply to a discussion the user started
|
| "quote" // reply quoting one of the user's posts
|
||||||
| "reply" // reply in a discussion the user took part in
|
|
||||||
| "mention" // mentioned in a discussion reply
|
| "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-reply" // chat reply to the user's message
|
||||||
| "chat-mention"; // mentioned in chat
|
| "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 = {
|
export type Notification = {
|
||||||
id: string;
|
id: string;
|
||||||
kind: NotificationKind;
|
kind: NotificationKind;
|
||||||
|
|
@ -43,11 +50,14 @@ export function parseNotification(e: Event, me: string): Notification | null {
|
||||||
if (e.kind === 1111) {
|
if (e.kind === 1111) {
|
||||||
const threadId = tag(e, "E");
|
const threadId = tag(e, "E");
|
||||||
if (!threadId) return null;
|
if (!threadId) return null;
|
||||||
const kind: NotificationKind = mentioned
|
const quoted = e.tags.some((t) => t[0] === "q" && t[3] === me);
|
||||||
? "mention"
|
const kind: NotificationKind = quoted
|
||||||
: tag(e, "P") === me
|
? "quote"
|
||||||
? "reply-op"
|
: mentioned
|
||||||
: "reply";
|
? "mention"
|
||||||
|
: tag(e, "P") === me
|
||||||
|
? "reply-op"
|
||||||
|
: "reply";
|
||||||
return { ...base, kind, threadId };
|
return { ...base, kind, threadId };
|
||||||
}
|
}
|
||||||
if (e.kind === 9) {
|
if (e.kind === 9) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue