Add notification count to dock icon on desktop

This commit is contained in:
Tom Moor
2023-05-20 18:01:55 -04:00
parent 965d85fb6f
commit 7e6831c803
5 changed files with 54 additions and 34 deletions

View File

@@ -10,6 +10,7 @@ import { markNotificationsAsRead } from "~/actions/definitions/notifications";
import useActionContext from "~/hooks/useActionContext";
import useStores from "~/hooks/useStores";
import { hover } from "~/styles";
import Desktop from "~/utils/Desktop";
import Empty from "../Empty";
import Flex from "../Flex";
import NudeButton from "../NudeButton";
@@ -36,6 +37,15 @@ function Notifications(
const { t } = useTranslation();
const isEmpty = notifications.orderedData.length === 0;
// Update the notification count in the dock icon, if possible.
React.useEffect(() => {
// Account for old versions of the desktop app that don't have the
// setNotificationCount method on the bridge.
if (Desktop.bridge && "setNotificationCount" in Desktop.bridge) {
Desktop.bridge.setNotificationCount(notifications.approximateUnreadCount);
}
}, [notifications.approximateUnreadCount]);
return (
<Flex style={{ width: "100%" }} column>
<Header justify="space-between">