From e0862a85ff5a1a6732bc698924dcab16c3153078 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 17 Feb 2024 15:47:17 +0100 Subject: [PATCH 01/15] fix(subplebbit settings): reset store, challenges setting would not update on subplebbitAddress change --- .../subplebbit/subplebbit-settings/subplebbit-settings.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx index 0c68c85b..84efb1c3 100644 --- a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx +++ b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx @@ -870,8 +870,8 @@ const SubplebbitSettings = () => { } }, [createdSubplebbit, navigate]); - // set the store with the initial data useEffect(() => { + resetSubplebbitSettingsStore(); if (subplebbitAddress) { setSubplebbitSettingsStore({ title: title ?? '', @@ -886,7 +886,7 @@ const SubplebbitSettings = () => { }); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [subplebbitAddress]); + }, [subplebbitAddress, resetSubplebbitSettingsStore]); useEffect(() => { if (isInCreateSubplebbitView) { From 2f815785fa707f5a7d38f56730d2ffa39bd18fef Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 17 Feb 2024 16:32:40 +0100 Subject: [PATCH 02/15] fix(subplebbit settings): read only exclude setting wasn't displayed properly --- src/lib/utils/challenge-utils.ts | 2 +- .../subplebbit-settings/subplebbit-settings.tsx | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lib/utils/challenge-utils.ts b/src/lib/utils/challenge-utils.ts index 8d61969c..36f09f82 100644 --- a/src/lib/utils/challenge-utils.ts +++ b/src/lib/utils/challenge-utils.ts @@ -132,7 +132,7 @@ export type OptionInput = { export type Exclude = { postScore?: number; - postReply?: number; + replyScore?: number; firstCommentTimestamp?: number; challenges?: number[]; post?: boolean; diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx index 84efb1c3..2712bf6e 100644 --- a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx +++ b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx @@ -515,7 +515,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings )} )} - {isReadOnly && !exclude?.postScore && !exclude?.postReply ? null : ( + {isReadOnly && !(exclude?.postScore || exclude?.replyScore) ? null : (
User's karma {isReadOnly && !exclude?.postScore ? null : ( @@ -528,13 +528,17 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings )} )} - {isReadOnly && !exclude?.postReply ? null : ( + {isReadOnly && !exclude?.replyScore ? null : ( <>
Comment karma is at least:
{isReadOnly ? ( - {exclude?.postReply} + {exclude?.replyScore} ) : ( - handleExcludeChange(excludeIndex, 'postReply', e.target.value)} /> + handleExcludeChange(excludeIndex, 'replyScore', e.target.value)} + /> )} )} @@ -580,7 +584,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings )}
)} - {isReadOnly && actionsToExclude.some((action) => exclude.hasOwnProperty(action)) ? null : ( + {isReadOnly && !actionsToExclude.some((action) => exclude[action] === true) ? null : (
User's action
Is all of the following:
@@ -604,7 +608,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings ), )} {nonActionsToExclude.map((nonAction) => - isReadOnly && exclude?.[nonAction.replace('not ', '')] ? null : ( + isReadOnly && exclude?.[nonAction.replace('not ', '')] !== null ? null : (
{isReadOnly ? ( {nonAction} excluded From 0a673991236fa8a1314746ccc2ada42ff83a3e33 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 17 Feb 2024 18:28:46 +0100 Subject: [PATCH 03/15] fix(post): dotted border for last visited post should only persist in the same window --- src/components/post/post.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/post/post.tsx b/src/components/post/post.tsx index 84ea1755..0802dd02 100644 --- a/src/components/post/post.tsx +++ b/src/components/post/post.tsx @@ -152,13 +152,13 @@ const Post = ({ index, post = {} }: PostProps) => { const { subscribe, subscribed } = useSubscribe({ subplebbitAddress }); // show gray dotted border around last clicked post - const isLastClicked = localStorage.getItem('lastClickedPost') === cid; + const isLastClicked = sessionStorage.getItem('lastClickedPost') === cid; const handlePostClick = () => { if (cid) { - if (localStorage.getItem('lastClickedPost') === cid) { - localStorage.removeItem('lastClickedPost'); + if (sessionStorage.getItem('lastClickedPost') === cid) { + sessionStorage.removeItem('lastClickedPost'); } else { - localStorage.setItem('lastClickedPost', cid); + sessionStorage.setItem('lastClickedPost', cid); } } }; From 292609b84f69d052c3888c25b084aa84e52a405b Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 17 Feb 2024 18:44:41 +0100 Subject: [PATCH 04/15] Update comment-tools.tsx --- src/components/post/comment-tools/comment-tools.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/post/comment-tools/comment-tools.tsx b/src/components/post/comment-tools/comment-tools.tsx index dba9578c..6dd1ac03 100644 --- a/src/components/post/comment-tools/comment-tools.tsx +++ b/src/components/post/comment-tools/comment-tools.tsx @@ -39,10 +39,10 @@ const PostTools = ({ author, cid, hasLabel, index, isAuthor, isMod, subplebbitAd // show gray dotted border around last clicked post const handlePostClick = () => { if (cid) { - if (localStorage.getItem('lastClickedPost') === cid) { - localStorage.removeItem('lastClickedPost'); + if (sessionStorage.getItem('lastClickedPost') === cid) { + sessionStorage.removeItem('lastClickedPost'); } else { - localStorage.setItem('lastClickedPost', cid); + sessionStorage.setItem('lastClickedPost', cid); } } }; From ff52a9a05e50770133a18648d8683242281cf0ad Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sun, 18 Feb 2024 11:38:53 +0100 Subject: [PATCH 05/15] fix(expando): clicking on video would redirect to external link --- src/components/post/expando/expando.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/post/expando/expando.tsx b/src/components/post/expando/expando.tsx index ea647449..17d4a683 100644 --- a/src/components/post/expando/expando.tsx +++ b/src/components/post/expando/expando.tsx @@ -24,16 +24,13 @@ const Expando = ({ commentMediaInfo, content, expanded, link, reason, removed, s const [showSpoiler, setShowSpoiler] = useState(false); let mediaComponent = null; - let noExpandButton = false; if (commentMediaInfo?.type === 'image') { mediaComponent = ; - noExpandButton = true; } else if (commentMediaInfo?.type === 'video' && expanded) { mediaComponent =