mirror of
https://github.com/smolgrrr/TAO.git
synced 2024-09-20 09:21:25 +00:00
remember toggle state in local storage
This commit is contained in:
parent
b6596d349e
commit
3394695dc5
@ -48,6 +48,7 @@ const NewNoteCard = ({
|
|||||||
const tags = tagMapping[tagType];
|
const tags = tagMapping[tagType];
|
||||||
if (tags) {
|
if (tags) {
|
||||||
tags.forEach(tag => unsigned.tags.push([tag, refEvent[tag === 'p' ? 'pubkey' : 'id']]));
|
tags.forEach(tag => unsigned.tags.push([tag, refEvent[tag === 'p' ? 'pubkey' : 'id']]));
|
||||||
|
// Ref event should be the latest event they're replying to, and their event should include prev replies
|
||||||
}
|
}
|
||||||
if (tagType === 'Quote') {
|
if (tagType === 'Quote') {
|
||||||
setComment(comment + '\nnostr:' + nip19.noteEncode(refEvent.id));
|
setComment(comment + '\nnostr:' + nip19.noteEncode(refEvent.id));
|
||||||
|
@ -29,8 +29,8 @@ const useUniqEvents = () => {
|
|||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
const filterDifficulty = localStorage.getItem("filterDifficulty") || DEFAULT_DIFFICULTY;
|
const filterDifficulty = localStorage.getItem("filterDifficulty") || DEFAULT_DIFFICULTY;
|
||||||
const [sortByTime, setSortByTime] = useState(true);
|
const [sortByTime, setSortByTime] = useState<boolean>(localStorage.getItem('sortBy') !== 'false');
|
||||||
const [setAnon, setSetAnon] = useState(true);
|
const [setAnon, setSetAnon] = useState<boolean>(localStorage.getItem('anonMode') !== 'false');
|
||||||
const { noteEvents, metadataEvents } = useUniqEvents();
|
const { noteEvents, metadataEvents } = useUniqEvents();
|
||||||
|
|
||||||
const postEvents = noteEvents
|
const postEvents = noteEvents
|
||||||
@ -49,11 +49,19 @@ const Home = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const toggleSort = useCallback(() => {
|
const toggleSort = useCallback(() => {
|
||||||
setSortByTime(prev => !prev);
|
setSortByTime(prev => {
|
||||||
|
const newValue = !prev;
|
||||||
|
localStorage.setItem('sortBy', String(newValue));
|
||||||
|
return newValue;
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const toggleAnon = useCallback(() => {
|
const toggleAnon = useCallback(() => {
|
||||||
setSetAnon(prev => !prev);
|
setSetAnon(prev => {
|
||||||
|
const newValue = !prev;
|
||||||
|
localStorage.setItem('anonMode', String(newValue));
|
||||||
|
return newValue;
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const countReplies = (event: Event) => {
|
const countReplies = (event: Event) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user