feat: hide untrusted content button

This commit is contained in:
codytseng
2025-06-09 01:08:50 +08:00
parent 5913cc3b88
commit 963051e70d
12 changed files with 177 additions and 57 deletions

View File

@@ -23,7 +23,7 @@ const NotificationList = forwardRef((_, ref) => {
const { t } = useTranslation()
const { current } = usePrimaryPage()
const { pubkey } = useNostr()
const { isUserTrusted } = useUserTrust()
const { hideUntrustedNotifications, isUserTrusted } = useUserTrust()
const { clearNewNotifications, getNotificationsSeenAt } = useNotification()
const { updateNoteStatsByEvents } = useNoteStats()
const [notificationType, setNotificationType] = useState<TNotificationType>('all')
@@ -124,9 +124,11 @@ const NotificationList = forwardRef((_, ref) => {
}, [pubkey, refreshCount, filterKinds, current])
useEffect(() => {
const visibleNotifications = notifications
.slice(0, showCount)
.filter((event) => isUserTrusted(event.pubkey))
let visibleNotifications = notifications.slice(0, showCount)
if (hideUntrustedNotifications) {
visibleNotifications = visibleNotifications.filter((event) => isUserTrusted(event.pubkey))
}
const index = visibleNotifications.findIndex((event) => event.created_at <= lastReadTime)
if (index === -1) {
setNewNotifications(visibleNotifications)
@@ -135,7 +137,7 @@ const NotificationList = forwardRef((_, ref) => {
setNewNotifications(visibleNotifications.slice(0, index))
setOldNotifications(visibleNotifications.slice(index))
}
}, [notifications, lastReadTime, showCount, isUserTrusted])
}, [notifications, lastReadTime, showCount, hideUntrustedNotifications, isUserTrusted])
useEffect(() => {
const options = {