feat: add toggle to hide untrusted posts (#435)
This commit is contained in:
parent
9da5e6663e
commit
98bf906916
5 changed files with 53 additions and 6 deletions
|
|
@ -6,8 +6,10 @@ import { useNostr } from './NostrProvider'
|
|||
type TUserTrustContext = {
|
||||
hideUntrustedInteractions: boolean
|
||||
hideUntrustedNotifications: boolean
|
||||
hideUntrustedNotes: boolean
|
||||
updateHideUntrustedInteractions: (hide: boolean) => void
|
||||
updateHideUntrustedNotifications: (hide: boolean) => void
|
||||
updateHideUntrustedNotes: (hide: boolean) => void
|
||||
isUserTrusted: (pubkey: string) => boolean
|
||||
}
|
||||
|
||||
|
|
@ -31,6 +33,9 @@ export function UserTrustProvider({ children }: { children: React.ReactNode }) {
|
|||
const [hideUntrustedNotifications, setHideUntrustedNotifications] = useState(() =>
|
||||
storage.getHideUntrustedNotifications()
|
||||
)
|
||||
const [hideUntrustedNotes, setHideUntrustedNotes] = useState(() =>
|
||||
storage.getHideUntrustedNotes ? storage.getHideUntrustedNotes() : false
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentPubkey) return
|
||||
|
|
@ -66,13 +71,22 @@ export function UserTrustProvider({ children }: { children: React.ReactNode }) {
|
|||
storage.setHideUntrustedNotifications(hide)
|
||||
}
|
||||
|
||||
const updateHideUntrustedNotes = (hide: boolean) => {
|
||||
setHideUntrustedNotes(hide)
|
||||
if (storage.setHideUntrustedNotes) {
|
||||
storage.setHideUntrustedNotes(hide)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<UserTrustContext.Provider
|
||||
value={{
|
||||
hideUntrustedInteractions,
|
||||
hideUntrustedNotifications,
|
||||
hideUntrustedNotes,
|
||||
updateHideUntrustedInteractions,
|
||||
updateHideUntrustedNotifications,
|
||||
updateHideUntrustedNotes,
|
||||
isUserTrusted
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue