feat(settings): add anon mode - automatically use a different user ID in each thread

This commit is contained in:
Tom (plebeius.eth)
2024-08-06 20:12:07 +02:00
parent f06c50ef33
commit db67a9452c
12 changed files with 334 additions and 77 deletions
+6 -4
View File
@@ -5,6 +5,7 @@ import useSelectedTextStore from '../stores/use-selected-text-store';
const useReplyModal = () => {
const [showReplyModal, setShowReplyModal] = useState(false);
const [activeCid, setActiveCid] = useState<string | null>(null);
const [threadCid, setThreadCid] = useState<string | null>(null);
const { resetSelectedText, setSelectedText } = useSelectedTextStore();
// on mobile, the css position is absolute instead of fixed, so we need to calculate the top position
@@ -22,7 +23,7 @@ const useReplyModal = () => {
text && setSelectedText(`>${text}\n`);
};
const openReplyModal = (cid: string) => {
const openReplyModal = (parentCid: string, postCid: string) => {
getSelectedText();
if (isMobile) {
@@ -30,14 +31,15 @@ const useReplyModal = () => {
setScrollY(currentScrollY);
}
if (activeCid && activeCid !== cid) {
if (activeCid && activeCid !== parentCid) {
return;
}
setActiveCid(cid);
setActiveCid(parentCid);
setThreadCid(postCid);
setShowReplyModal(true);
};
return { activeCid, closeModal, openReplyModal, scrollY, showReplyModal };
return { activeCid, threadCid, closeModal, openReplyModal, scrollY, showReplyModal };
};
export default useReplyModal;