fix: 🐛 service worker notification badges

This commit is contained in:
ThatOneCalculator 2023-12-04 19:07:26 -08:00
parent 342166c01f
commit 00f8924030
No known key found for this signature in database
GPG key ID: 8703CACD01000000
10 changed files with 26 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

Before

Width:  |  Height:  |  Size: 889 B

After

Width:  |  Height:  |  Size: 889 B

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 798 B

View file

@ -222,6 +222,12 @@ export type Notification = {
userId: User["id"]; userId: User["id"];
note: Note; note: Note;
} }
| {
type: "pollEnded";
user: User;
userId: User["id"];
note: Note;
}
| { | {
type: "follow"; type: "follow";
user: User; user: User;

View file

@ -19,11 +19,11 @@ const closeNotificationsByTags = async (tags: string[]): Promise<void> => {
}; };
const iconUrl = (name: BadgeNames): string => const iconUrl = (name: BadgeNames): string =>
`/static-assets/tabler-badges/${name}.png`; `/static-assets/notification-badges/${name}.png`;
/* How to add a new badge: /* How to add a new badge:
* 1. Find the icon and download png from https://tabler-icons.io/ * 1. Find the icon from https://phosphoricons.com/
* 2. vips resize ~/Downloads/icon-name.png vipswork.png 0.4; vips scRGB2BW vipswork.png ~/icon-name.png"[compression=9,strip]"; rm vipswork.png; * 2. Choose #000000 as the color, 96px as the size, and bold as the weight
* 3. mv ~/icon-name.png ~/misskey/packages/backend/assets/tabler-badges/ * 3. Move icon-name.png to packages/backend/assets/notification-badges/
* 4. Add 'icon-name' to BadgeNames * 4. Add 'icon-name' to BadgeNames
* 5. Add `badge: iconUrl('icon-name'),` * 5. Add `badge: iconUrl('icon-name'),`
*/ */
@ -131,7 +131,7 @@ async function composeNotification(
{ {
body: data.body.note.text || "", body: data.body.note.text || "",
icon: data.body.user.avatarUrl, icon: data.body.user.avatarUrl,
badge: iconUrl("retweet"), badge: iconUrl("boost"),
data, data,
actions: [ actions: [
{ {
@ -150,7 +150,7 @@ async function composeNotification(
{ {
body: data.body.note.text || "", body: data.body.note.text || "",
icon: data.body.user.avatarUrl, icon: data.body.user.avatarUrl,
badge: iconUrl("quote-right"), badge: iconUrl("quote"),
data, data,
actions: [ actions: [
{ {
@ -182,8 +182,7 @@ async function composeNotification(
badge = badgeUrl.href; badge = badgeUrl.href;
reaction = name.split("@")[0]; reaction = name.split("@")[0];
} else { } else {
// Unicode絵文字の場合 badge = iconUrl("reaction");
badge = `/twemoji-badge/${char2fileName(reaction)}.png`;
} }
if ( if (
@ -219,7 +218,7 @@ async function composeNotification(
{ {
body: data.body.note.text || "", body: data.body.note.text || "",
icon: data.body.user.avatarUrl, icon: data.body.user.avatarUrl,
badge: iconUrl("poll-h"), badge: iconUrl("poll"),
data, data,
}, },
]; ];
@ -229,7 +228,7 @@ async function composeNotification(
t("_notification.pollEnded"), t("_notification.pollEnded"),
{ {
body: data.body.note.text || "", body: data.body.note.text || "",
badge: iconUrl("clipboard-check-solid"), badge: iconUrl("clipboard-check"),
data, data,
}, },
]; ];
@ -273,7 +272,7 @@ async function composeNotification(
}), }),
{ {
body: data.body.invitation.group.name, body: data.body.invitation.group.name,
badge: iconUrl("id-card-alt"), badge: iconUrl("id-card"),
data, data,
actions: [ actions: [
{ {

View file

@ -37,15 +37,17 @@ export type PushNotificationDataMap = {
export type BadgeNames = export type BadgeNames =
| "null" | "null"
| "antenna"
| "arrow-back-up"
| "at" | "at"
| "chart-arrows" | "boost"
| "circle-check" | "check"
| "medal" | "clipboard-check"
| "clock"
| "comments"
| "id-card"
| "messages" | "messages"
| "plus" | "plus"
| "poll"
| "quote" | "quote"
| "repeat" | "reaction"
| "user-plus" | "reply"
| "users"; | "user-plus";