fix(desktop): sync dock badge with unread count
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { isMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { useUnreadAll } from "@follow/store/unread/hooks"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import i18next from "i18next"
|
||||
import { useEffect, useInsertionEffect, useLayoutEffect } from "react"
|
||||
|
||||
@@ -11,6 +13,18 @@ import { langChain } from "~/i18n"
|
||||
import { ipcServices } from "~/lib/client"
|
||||
import { loadLanguageAndApply } from "~/lib/load-language"
|
||||
|
||||
const useUpdateDockBadge = () => {
|
||||
const unreadCount = useUnreadAll()
|
||||
const { mutate, isPending } = useMutation({
|
||||
mutationFn: async (unread: number) => ipcServices?.dock.setDockBadge(unread),
|
||||
})
|
||||
useEffect(() => {
|
||||
if (!isPending) {
|
||||
mutate(unreadCount)
|
||||
}
|
||||
}, [unreadCount, mutate, isPending])
|
||||
}
|
||||
|
||||
const useUISettingSync = () => {
|
||||
const setting = useUISettingValue()
|
||||
const mobile = isMobile()
|
||||
@@ -45,6 +59,8 @@ const useUISettingSync = () => {
|
||||
}
|
||||
return
|
||||
}, [setting.showDockBadge])
|
||||
|
||||
useUpdateDockBadge()
|
||||
}
|
||||
|
||||
const useUXSettingSync = () => {
|
||||
|
||||
Reference in New Issue
Block a user