Compare commits
No commits in common. "f3ab7f6d6ac1759cfcc23d155b9d61dbf18d0e31" and "9a30eae749f88795ac5f841474a68e9e3f169a1f" have entirely different histories.
f3ab7f6d6a
...
9a30eae749
@ -10,14 +10,12 @@ import { log, LogType, now } from 'utils'
|
|||||||
|
|
||||||
// todo: use components from Input.tsx
|
// todo: use components from Input.tsx
|
||||||
export const PreferencesSetting = () => {
|
export const PreferencesSetting = () => {
|
||||||
const { ndk, fetchEventFromUserRelays, publish } = useNDKContext()
|
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
const user = useAppSelector((state) => state.user.user)
|
const [wotLevel, setWotLevel] = useState(3)
|
||||||
const { userWotLevel } = useAppSelector((state) => state.wot)
|
|
||||||
|
|
||||||
const [wotLevel, setWotLevel] = useState(userWotLevel)
|
|
||||||
const [isSaving, setIsSaving] = useState(false)
|
const [isSaving, setIsSaving] = useState(false)
|
||||||
|
const { ndk, fetchEventFromUserRelays, publish } = useNDKContext()
|
||||||
|
const user = useAppSelector((state) => state.user.user)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user?.pubkey) {
|
if (user?.pubkey) {
|
||||||
@ -82,22 +80,9 @@ export const PreferencesSetting = () => {
|
|||||||
|
|
||||||
const ndkEvent = new NDKEvent(ndk, signedEvent)
|
const ndkEvent = new NDKEvent(ndk, signedEvent)
|
||||||
await publish(ndkEvent)
|
await publish(ndkEvent)
|
||||||
.then((publishedOnRelays) => {
|
dispatch(setUserWotLevel(wotLevel))
|
||||||
toast.success(
|
|
||||||
`Preferences published to following relays: \n\n${publishedOnRelays.join(
|
|
||||||
'\n'
|
|
||||||
)}`
|
|
||||||
)
|
|
||||||
|
|
||||||
dispatch(setUserWotLevel(wotLevel))
|
setIsSaving(false)
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err)
|
|
||||||
toast.error('Error: Failed to publish preferences!')
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
setIsSaving(false)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -19,10 +19,10 @@ export interface IWOT {
|
|||||||
const initialState: IWOT = {
|
const initialState: IWOT = {
|
||||||
siteWot: [],
|
siteWot: [],
|
||||||
siteWotStatus: WOTStatus.IDLE,
|
siteWotStatus: WOTStatus.IDLE,
|
||||||
siteWotLevel: 0,
|
siteWotLevel: 3,
|
||||||
userWot: [],
|
userWot: [],
|
||||||
userWotStatus: WOTStatus.IDLE,
|
userWotStatus: WOTStatus.IDLE,
|
||||||
userWotLevel: 0
|
userWotLevel: 3
|
||||||
}
|
}
|
||||||
|
|
||||||
export const wotSlice = createSlice({
|
export const wotSlice = createSlice({
|
||||||
|
Loading…
Reference in New Issue
Block a user