refactor(wot): update redux wot level if admin wot npub changes level
This commit is contained in:
parent
8b5b9a6e30
commit
02a81213a2
@ -123,6 +123,7 @@ export const useFilteredMods = (
|
|||||||
|
|
||||||
return filtered
|
return filtered
|
||||||
}, [
|
}, [
|
||||||
|
userState.auth,
|
||||||
userState.user?.npub,
|
userState.user?.npub,
|
||||||
filterOptions.sort,
|
filterOptions.sort,
|
||||||
filterOptions.moderated,
|
filterOptions.moderated,
|
||||||
|
@ -4,9 +4,9 @@ import { useAppDispatch, useAppSelector, useNDKContext } from 'hooks'
|
|||||||
import { kinds, UnsignedEvent, Event } from 'nostr-tools'
|
import { kinds, UnsignedEvent, Event } from 'nostr-tools'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
import { setUserWotLevel } from 'store/reducers/wot'
|
import { setSiteWotLevel, setUserWotLevel } from 'store/reducers/wot'
|
||||||
import { UserRelaysType } from 'types'
|
import { UserRelaysType } from 'types'
|
||||||
import { log, LogType, now } from 'utils'
|
import { log, LogType, now, npubToHex } from 'utils'
|
||||||
|
|
||||||
// todo: use components from Input.tsx
|
// todo: use components from Input.tsx
|
||||||
export const PreferencesSetting = () => {
|
export const PreferencesSetting = () => {
|
||||||
@ -92,6 +92,13 @@ export const PreferencesSetting = () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
dispatch(setUserWotLevel(wotLevel))
|
dispatch(setUserWotLevel(wotLevel))
|
||||||
|
|
||||||
|
// If wot admin, update site wot level too
|
||||||
|
const SITE_WOT_NPUB = import.meta.env.VITE_SITE_WOT_NPUB
|
||||||
|
const siteWotPubkey = npubToHex(SITE_WOT_NPUB)
|
||||||
|
if (siteWotPubkey === hexPubkey) {
|
||||||
|
dispatch(setSiteWotLevel(wotLevel))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user