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.0 KiB

After

Width:  |  Height:  |  Size: 1.0 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"];
note: Note;
}
| {
type: "pollEnded";
user: User;
userId: User["id"];
note: Note;
}
| {
type: "follow";
user: User;

View File

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

View File

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