Skip to content

Commit

Permalink
Fix badge
Browse files Browse the repository at this point in the history
  • Loading branch information
K0IN committed Aug 28, 2023
1 parent 53036ba commit fb92af2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/frontend/src/components/messages/messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useLastOpenTime } from '../../hooks/use-lastopen';
import { useMessageReceiver } from '../../hooks/use-messagereceiver';
import Message from '../message/message';
import style from './messages.css';
import { useEffect } from 'preact/hooks';

const Messages: FunctionalComponent = () => {
const messages = useMessageReceiver();
Expand All @@ -12,6 +13,12 @@ const Messages: FunctionalComponent = () => {
const newMessages = messages.filter(e => !(e.receivedAt <= lastOpenTime));
const oldMessages = messages.filter(e => e.receivedAt <= lastOpenTime);

useEffect(() => {
if (navigator && navigator.clearAppBadge) {
navigator.clearAppBadge();
}
}, [messages]);

return (<div class={style.content}>
<div class={style.main}>
<ul class={style.messagelist}>
Expand Down
3 changes: 3 additions & 0 deletions app/frontend/src/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ self.addEventListener('push', (event) => {
self.addEventListener('notificationclick', (e) => {
const notification = e.notification;
const load = async () => {
if (navigator && navigator.clearAppBadge) {
navigator.clearAppBadge();
}
try {
const clientList = await clients.matchAll();
if (clientList.length > 0) {
Expand Down

0 comments on commit fb92af2

Please sign in to comment.