forked from FoundKeyGang/FoundKey
Send notifications also when the tab is not visible
This commit is contained in:
parent
e44be45c90
commit
ed515cc24c
1 changed files with 48 additions and 54 deletions
|
@ -36,61 +36,55 @@ const dev: Ref<boolean> = ref(_DEV_);
|
||||||
const onNotification = (notification: foundkey.entities.Notification): void => {
|
const onNotification = (notification: foundkey.entities.Notification): void => {
|
||||||
if ($i?.mutingNotificationTypes.includes(notification.type)) return;
|
if ($i?.mutingNotificationTypes.includes(notification.type)) return;
|
||||||
|
|
||||||
if (document.visibilityState === 'visible') {
|
if (notification.type !== 'app') {
|
||||||
stream.send('readNotification', {
|
const user = notification.user;
|
||||||
id: notification.id,
|
const userName = acct(user);
|
||||||
});
|
let title: string;
|
||||||
|
let body = 'note' in notification ? getNoteSummary(notification.note) : undefined;
|
||||||
if (notification.type !== 'app') {
|
switch (notification.type) {
|
||||||
const user = notification.user;
|
case 'pollEnded':
|
||||||
const userName = acct(user);
|
title = `${userName}'s poll has ended`;
|
||||||
let title: string;
|
break;
|
||||||
let body = 'note' in notification ? getNoteSummary(notification.note) : undefined;
|
case 'follow':
|
||||||
switch (notification.type) {
|
title = `${userName} followed you`;
|
||||||
case 'pollEnded':
|
break;
|
||||||
title = `${userName}'s poll has ended`;
|
case 'followRequestAccepted':
|
||||||
break;
|
title = `${userName} accepted your follow request`;
|
||||||
case 'follow':
|
break;
|
||||||
title = `${userName} followed you`;
|
case 'mention':
|
||||||
break;
|
title = `${userName} mentioned you`;
|
||||||
case 'followRequestAccepted':
|
break;
|
||||||
title = `${userName} accepted your follow request`;
|
case 'pollVote':
|
||||||
break;
|
title = `${userName} voted in your poll`;
|
||||||
case 'mention':
|
break;
|
||||||
title = `${userName} mentioned you`;
|
case 'quote':
|
||||||
break;
|
title = `${userName} quoted your post`;
|
||||||
case 'pollVote':
|
break;
|
||||||
title = `${userName} voted in your poll`;
|
case 'reaction':
|
||||||
break;
|
title = `${userName} ${notification.reaction}ed your post`;
|
||||||
case 'quote':
|
break;
|
||||||
title = `${userName} quoted your post`;
|
case 'receiveFollowRequest':
|
||||||
break;
|
title = `${userName} sent you a follow request`;
|
||||||
case 'reaction':
|
break;
|
||||||
title = `${userName} ${notification.reaction}ed your post`;
|
case 'renote':
|
||||||
break;
|
title = `${userName} renoted your post`;
|
||||||
case 'receiveFollowRequest':
|
break;
|
||||||
title = `${userName} sent you a follow request`;
|
case 'reply':
|
||||||
break;
|
title = `${userName} replied to your post`;
|
||||||
case 'renote':
|
break;
|
||||||
title = `${userName} renoted your post`;
|
case 'groupInvited':
|
||||||
break;
|
title = `${userName} invited you to a group`;
|
||||||
case 'reply':
|
break;
|
||||||
title = `${userName} replied to your post`;
|
|
||||||
break;
|
|
||||||
case 'groupInvited':
|
|
||||||
title = `${userName} invited you to a group`;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(user, userName, title, body);
|
|
||||||
new Notification(title, {
|
|
||||||
body,
|
|
||||||
image: user.avatarUrl,
|
|
||||||
icon: instance.iconUrl,
|
|
||||||
// TODO: timestamp?
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
console.log(user, userName, title, body);
|
||||||
|
new Notification(title, {
|
||||||
|
body,
|
||||||
|
image: user.avatarUrl,
|
||||||
|
icon: instance.iconUrl,
|
||||||
|
// TODO: timestamp?
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
sound.play('notification');
|
sound.play('notification');
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue