refactor: use local storage instead of session for nsfw preference

This commit is contained in:
enes 2024-12-03 17:32:55 +01:00
parent 1ee56ba91a
commit 71f934129c
3 changed files with 6 additions and 6 deletions

View File

@ -2,7 +2,7 @@ import { FilterOptions, NSFWFilter } from 'types'
import { Option } from './Option'
import { NsfwAlertPopup } from 'components/NsfwAlertPopup'
import { useState } from 'react'
import { useLocalStorage, useSessionStorage } from 'hooks'
import { useLocalStorage } from 'hooks'
import { DEFAULT_FILTER_OPTIONS } from 'utils'
interface NsfwFilterOptionsProps {
@ -18,7 +18,7 @@ export const NsfwFilterOptions = ({ filterKey }: NsfwFilterOptionsProps) => {
const [selectedNsfwOption, setSelectedNsfwOption] = useState<
NSFWFilter | undefined
>()
const [confirmNsfw] = useSessionStorage<boolean>('confirm-nsfw', false)
const [confirmNsfw] = useLocalStorage<boolean>('confirm-nsfw', false)
const handleConfirm = (confirm: boolean) => {
if (confirm && selectedNsfwOption) {
setFilterOptions((prev) => ({

View File

@ -1,6 +1,6 @@
import { AlertPopupProps } from 'types'
import { AlertPopup } from './AlertPopup'
import { useSessionStorage } from 'hooks'
import { useLocalStorage } from 'hooks'
type NsfwAlertPopup = Omit<AlertPopupProps, 'header' | 'label'>
@ -14,7 +14,7 @@ export const NsfwAlertPopup = ({
handleConfirm,
handleClose
}: NsfwAlertPopup) => {
const [confirmNsfw, setConfirmNsfw] = useSessionStorage<boolean>(
const [confirmNsfw, setConfirmNsfw] = useLocalStorage<boolean>(
'confirm-nsfw',
false
)

View File

@ -5,7 +5,7 @@ import {
useAppDispatch,
useAppSelector,
useNDKContext,
useSessionStorage
useLocalStorage
} from 'hooks'
import { kinds, UnsignedEvent, Event } from 'nostr-tools'
import { useEffect, useState } from 'react'
@ -26,7 +26,7 @@ export const PreferencesSetting = () => {
const [isSaving, setIsSaving] = useState(false)
const [nsfw, setNsfw] = useState(false)
const [confirmNsfw] = useSessionStorage<boolean>('confirm-nsfw', false)
const [confirmNsfw] = useLocalStorage<boolean>('confirm-nsfw', false)
const [showNsfwPopup, setShowNsfwPopup] = useState<boolean>(false)
const handleNsfwConfirm = (confirm: boolean) => {
setNsfw(confirm)