mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-14 04:08:32 +03:00
More reliable badge clearing
Should be when page visible, not on render Possibly super effective, but badges can be annoying if not cleared easily.
This commit is contained in:
parent
d4dce2fa45
commit
6cbbd0aa1b
2 changed files with 9 additions and 13 deletions
|
@ -7,6 +7,7 @@ import {
|
|||
getAccountByAccessToken,
|
||||
getCurrentAccount,
|
||||
} from '../utils/store-utils';
|
||||
import usePageVisibility from '../utils/usePageVisibility';
|
||||
|
||||
import Icon from './icon';
|
||||
import Link from './link';
|
||||
|
@ -104,6 +105,13 @@ export default function NotificationService() {
|
|||
};
|
||||
}, []);
|
||||
|
||||
usePageVisibility((visible) => {
|
||||
if (visible && navigator?.clearAppBadge) {
|
||||
console.log('🔰 Clear app badge');
|
||||
navigator.clearAppBadge();
|
||||
}
|
||||
});
|
||||
|
||||
const onClose = () => {
|
||||
setShowNotificationSheet(false);
|
||||
states.routeNotification = null;
|
||||
|
|
|
@ -2,13 +2,7 @@ import './notifications.css';
|
|||
|
||||
import { useIdle } from '@uidotdev/usehooks';
|
||||
import { memo } from 'preact/compat';
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'preact/hooks';
|
||||
import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
|
@ -200,12 +194,6 @@ function Notifications({ columnMode }) {
|
|||
|
||||
const announcementsListRef = useRef();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (navigator.clearAppBadge) {
|
||||
navigator.clearAppBadge();
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (notificationID) {
|
||||
states.routeNotification = {
|
||||
|
|
Loading…
Add table
Reference in a new issue