mirror of
https://github.com/block/buzz.git
synced 2026-11-16 06:11:34 +00:00
refactor(desktop): consolidate notification helpers and add channel names to toasts (#1286)
Signed-off-by: Will Pfleger <pfleger.will@gmail.com> Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
@@ -13,6 +13,10 @@ import {
|
||||
revealDesktopAppWindow,
|
||||
sendDesktopNotification,
|
||||
} from "@/features/notifications/lib/desktop";
|
||||
import {
|
||||
formatNotificationTitle,
|
||||
truncateNotificationBody,
|
||||
} from "@/features/notifications/lib/notificationFormat";
|
||||
import {
|
||||
playNotificationSound,
|
||||
resolveSlotSound,
|
||||
@@ -54,13 +58,7 @@ export function useAppShellDesktopNotifications({
|
||||
}
|
||||
|
||||
const channelName = channel.name?.trim() || "Direct message";
|
||||
const content = event.content.trim();
|
||||
const body =
|
||||
content.length > 0
|
||||
? content.length > 140
|
||||
? `${content.slice(0, 137).trimEnd()}...`
|
||||
: content
|
||||
: "New message";
|
||||
const body = truncateNotificationBody(event.content, "New message");
|
||||
const threadRootId = getThreadReference(event.tags).rootId ?? null;
|
||||
|
||||
void sendDesktopNotification({
|
||||
@@ -100,19 +98,16 @@ export function useAppShellDesktopNotifications({
|
||||
return;
|
||||
}
|
||||
|
||||
const channel = channels.find((entry) => entry.id === channelId);
|
||||
const channelName = channel?.name?.trim() || "Thread";
|
||||
const content = event.content.trim();
|
||||
const body =
|
||||
content.length > 0
|
||||
? content.length > 140
|
||||
? `${content.slice(0, 137).trimEnd()}...`
|
||||
: content
|
||||
: "New reply";
|
||||
const resolvedChannel = channels.find((c) => c.id === channelId);
|
||||
const channelName = resolvedChannel?.name?.trim() ?? null;
|
||||
// channelLabel is "#name" for the toast title; channelName is the raw
|
||||
// name stored in the navigation target for click-through routing.
|
||||
const channelLabel = channelName ? `#${channelName}` : null;
|
||||
const body = truncateNotificationBody(event.content, "New reply");
|
||||
const threadRootId = getThreadReference(event.tags).rootId ?? null;
|
||||
|
||||
void sendDesktopNotification({
|
||||
title: `Reply in ${channelName}`,
|
||||
title: formatNotificationTitle({ prefix: "Reply", channelLabel }),
|
||||
body,
|
||||
target: {
|
||||
channelId,
|
||||
|
||||
Reference in New Issue
Block a user