Settings > General gets an App icon (super admin): one of the seven stones, or an uploaded image with the picked stone as a top-left corner mark (inside a round launcher's crop, clear of the browser's badge), previewed in both launcher crops before saving. Uploads are decoded and cropped to a stored square (no SVG); the set is drawn into DATA_DIR/install-icon/<version>/ and served publicly and immutable. The manifest, head icon links and push notifications point at it; the ember stone keeps the stock icons. The generator shares the icon renderer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { AppData } from "@/src/data/app-data";
|
|
|
|
/**
|
|
* A notification's payload. The service worker turns it into a
|
|
* notification; `url` is where clicking it goes.
|
|
*/
|
|
export type PushPayload = {
|
|
title: string;
|
|
body: string;
|
|
url: string;
|
|
tag: string;
|
|
requireInteraction?: boolean;
|
|
/**
|
|
* The install's own icon (`deliverToUser` fills it in); the worker
|
|
* falls back to the stock one.
|
|
*/
|
|
icon?: string;
|
|
};
|
|
|
|
/**
|
|
* One conversation replaces its previous notification, so a burst does not
|
|
* stack. A needs-you notice has its own tag.
|
|
*/
|
|
export function pushMessageTag({
|
|
bot_id,
|
|
session_id,
|
|
}: {
|
|
bot_id: number | string;
|
|
session_id: number | string;
|
|
}) {
|
|
return `bot-${bot_id}-session-${session_id}`;
|
|
}
|
|
|
|
export function pushNeedsYouTag({ bot_id }: { bot_id: number | string }) {
|
|
return `bot-${bot_id}-needs-you`;
|
|
}
|
|
|
|
export function truncatePushBody(text: string) {
|
|
const limit = AppData.PushBodyMaxChars;
|
|
|
|
if (text.length <= limit) return text;
|
|
|
|
return `${text.slice(0, limit - 1).trimEnd()}…`;
|
|
}
|
|
|
|
export const PushDefaultIcon = "/icons/icon-192.png";
|