feat: filter new notifications from muted users
This commit is contained in:
parent
616c5bdd50
commit
d79f5d0722
1 changed files with 4 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ import dayjs from 'dayjs'
|
||||||
import { kinds } from 'nostr-tools'
|
import { kinds } from 'nostr-tools'
|
||||||
import { SubCloser } from 'nostr-tools/abstract-pool'
|
import { SubCloser } from 'nostr-tools/abstract-pool'
|
||||||
import { createContext, useContext, useEffect, useRef, useState } from 'react'
|
import { createContext, useContext, useEffect, useRef, useState } from 'react'
|
||||||
|
import { useMuteList } from './MuteListProvider'
|
||||||
import { useNostr } from './NostrProvider'
|
import { useNostr } from './NostrProvider'
|
||||||
|
|
||||||
type TNotificationContext = {
|
type TNotificationContext = {
|
||||||
|
|
@ -24,6 +25,7 @@ export const useNotification = () => {
|
||||||
|
|
||||||
export function NotificationProvider({ children }: { children: React.ReactNode }) {
|
export function NotificationProvider({ children }: { children: React.ReactNode }) {
|
||||||
const { pubkey } = useNostr()
|
const { pubkey } = useNostr()
|
||||||
|
const { mutePubkeys } = useMuteList()
|
||||||
const { current } = usePrimaryPage()
|
const { current } = usePrimaryPage()
|
||||||
const [hasNewNotification, setHasNewNotification] = useState(false)
|
const [hasNewNotification, setHasNewNotification] = useState(false)
|
||||||
const [lastReadTime, setLastReadTime] = useState(-1)
|
const [lastReadTime, setLastReadTime] = useState(-1)
|
||||||
|
|
@ -83,7 +85,8 @@ export function NotificationProvider({ children }: { children: React.ReactNode }
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onevent: (evt) => {
|
onevent: (evt) => {
|
||||||
if (evt.pubkey !== pubkey) {
|
// Only show notification if not from self and not muted
|
||||||
|
if (evt.pubkey !== pubkey && !mutePubkeys.includes(evt.pubkey)) {
|
||||||
setHasNewNotification(true)
|
setHasNewNotification(true)
|
||||||
subCloser.close()
|
subCloser.close()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue