feat: filter new notifications from muted users
This commit is contained in:
@@ -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()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user