From bce924e90ff143d2bac51b4d6833a56be670b523 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Thu, 28 Sep 2023 13:17:56 +0200 Subject: [PATCH 1/9] style(post menu): add post menu styling to yotsuba --- .../styled/views/Catalog.styled.jsx | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/src/components/styled/views/Catalog.styled.jsx b/src/components/styled/views/Catalog.styled.jsx index f830e5ad..2f9460b3 100644 --- a/src/components/styled/views/Catalog.styled.jsx +++ b/src/components/styled/views/Catalog.styled.jsx @@ -17,12 +17,14 @@ export const Threads = styled.div` padding: 5px 0 3px; } - video, audio, img { + video, + audio, + img { max-width: 150px; max-height: 150px; -} + } -.file-thumb { + .file-thumb { background-color: rgba(0, 0, 0, 0.05); display: inline-flex; justify-content: center; @@ -31,8 +33,8 @@ export const Threads = styled.div` } .card { - box-shadow: 0 0 5px rgba(0, 0, 0, .25); - border: 0; + box-shadow: 0 0 5px rgba(0, 0, 0, 0.25); + border: 0; } .thread-icons { @@ -64,7 +66,7 @@ export const Threads = styled.div` } .offline-icon-no-link-hovered { - transform: translate(16px,0); + transform: translate(16px, 0); } .sticky-icon { background-image: url(assets/sticky.gif); @@ -94,7 +96,6 @@ export const Threads = styled.div` word-wrap: break-word; } - ${({ selectedStyle }) => { switch (selectedStyle) { case 'Yotsuba': @@ -155,7 +156,6 @@ export const PostPreview = styled.div` font-weight: 700; } - ${({ selectedStyle }) => { switch (selectedStyle) { case 'Yotsuba': @@ -284,9 +284,27 @@ export const PostMenuCatalog = styled.div` ${({ selectedStyle }) => { switch (selectedStyle) { case 'Yotsuba': - return `.post-subject{ - color:red; - }`; + return `.highlighted, .highlighted-click, .highlighted-address { + background-color: #f0c0b0 !important; + border: 1px solid #d9bfb7 !important; + border-left: none !important; + border-top: none !important; + } + + .post-menu-catalog { + border-right: 1px solid #d9bfb7; + border-bottom: 2px solid #d9bfb7; + + li { + border: 1px solid #d9bfb7; + background-color: #f0e0d6; + border-bottom: none; + + :hover { + background-color: #ffe; + } + } + }`; case 'Yotsuba-B': return `.highlighted, .highlighted-click, .highlighted-address { @@ -395,9 +413,8 @@ export const PostMenuCatalog = styled.div` } }`; - - default: - return ''; - } - }} -`; \ No newline at end of file + default: + return ''; + } + }} +`; From b6cdc00843473a61cf158acca278f299dfa7ce34 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Thu, 28 Sep 2023 21:05:03 +0200 Subject: [PATCH 2/9] refactor(state): rename isModerator to canModerate for precision --- src/components/views/All.jsx | 10 +++---- src/components/views/AllCatalog.jsx | 8 +++--- src/components/views/Board.jsx | 20 +++++++------- src/components/views/Catalog.jsx | 16 ++++++------ src/components/views/Description.jsx | 2 +- src/components/views/Rules.jsx | 2 +- src/components/views/Subscriptions.jsx | 10 +++---- src/components/views/SubscriptionsCatalog.jsx | 8 +++--- src/components/views/Thread.jsx | 14 +++++----- src/hooks/stores/useGeneralStore.js | 26 +++++++++---------- 10 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/components/views/All.jsx b/src/components/views/All.jsx index 1d137029..dcd03dda 100755 --- a/src/components/views/All.jsx +++ b/src/components/views/All.jsx @@ -717,7 +717,7 @@ const All = () => { const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {}; const commentMediaInfo = getCommentMediaInfo(thread); const fallbackImgUrl = 'assets/filedeleted-res.gif'; - const isModerator = moderatorPermissions[thread.subplebbitAddress]; + const canModerate = moderatorPermissions[thread.subplebbitAddress]; let displayWidth, displayHeight, displayWidthMobile, displayHeightMobile; if (thread.linkWidth && thread.linkHeight) { let scale = Math.min(1, 250 / Math.max(thread.linkWidth, thread.linkHeight)); @@ -1037,7 +1037,7 @@ const All = () => {
  • handleAuthorDeleteClick(thread)}>Delete post
  • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
  • {
  • handleAuthorDeleteClick(reply)}>Delete post
  • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
  • {
  • handleAuthorDeleteClick(thread)}>Delete post
  • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
  • {
  • handleAuthorDeleteClick(reply)}>Delete post
  • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
  • { const [isImageSearchOpen, setIsImageSearchOpen] = useState(false); const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false); const [commentCid, setCommentCid] = useState(null); - const [isModerator, setIsModerator] = useState(false); + const [canModerate, setCanModerate] = useState(false); const [, setNewErrorMessage] = useError(); const [, setNewSuccessMessage] = useSuccess(); @@ -161,9 +161,9 @@ const CatalogPost = ({ post }) => { const role = subplebbit.roles[account?.author.address]?.role; if (role === 'moderator' || role === 'admin' || role === 'owner') { - setIsModerator(true); + setCanModerate(true); } else { - setIsModerator(false); + setCanModerate(false); } } }, [account?.author.address, subplebbit.roles]); @@ -573,7 +573,7 @@ const CatalogPost = ({ post }) => {
  • handleAuthorDeleteClick(thread)}>Delete post
  • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
  • { const [deletePost, setDeletePost] = useState(false); const [isImageSearchOpen, setIsImageSearchOpen] = useState(false); const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false); - const [isModerator, setIsModerator] = useState(false); + const [canModerate, setCanModerate] = useState(false); const [commentCid, setCommentCid] = useState(null); const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 }); const [mobileMenuPosition, setMobileMenuPosition] = useState({ top: 0, left: 0 }); @@ -180,9 +180,9 @@ const Board = () => { const role = subplebbit?.roles[account?.author.address]?.role; if (role === 'moderator' || role === 'admin' || role === 'owner') { - setIsModerator(true); + setCanModerate(true); } else { - setIsModerator(false); + setCanModerate(false); } } }, [account?.author.address, subplebbit?.roles]); @@ -1039,7 +1039,7 @@ const Board = () => { >
      - {/* {isModerator ? ( + {/* {canModerate ? ( <> change rules @@ -1264,7 +1264,7 @@ const Board = () => { >
        - {/* {isModerator ? ( + {/* {canModerate ? ( <> change rules @@ -1509,7 +1509,7 @@ const Board = () => { style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }} >
          - {/* {isModerator ? ( + {/* {canModerate ? ( <> change description @@ -2080,7 +2080,7 @@ const Board = () => {
        • handleAuthorDeleteClick(thread)}>Delete post
        • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
        • {
        • handleAuthorDeleteClick(reply)}>Delete post
        • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
        • {
        • handleAuthorDeleteClick(thread)}>Delete post
        • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
        • {
        • handleAuthorDeleteClick(reply)}>Delete post
        • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
        • { setIsAuthorEdit, setIsCaptchaOpen, setIsEditModalOpen, - isModerator, + canModerate, setModeratingCommentCid, setOriginalCommentContent, setPendingComment, @@ -443,7 +443,7 @@ const CatalogPost = ({ post }) => { >
            - {/* {isModerator ? ( + {/* {canModerate ? ( <> change rules @@ -647,7 +647,7 @@ const CatalogPost = ({ post }) => { >
              - {/* {isModerator ? ( + {/* {canModerate ? ( <> change description @@ -999,7 +999,7 @@ const CatalogPost = ({ post }) => {
            • handleAuthorDeleteClick(thread)}>Delete post
            • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
            • { setIsCaptchaOpen, isModerationOpen, setIsModerationOpen, - setIsModerator, + setCanModerate, isSettingsOpen, setIsSettingsOpen, originalCommentContent, @@ -1198,12 +1198,12 @@ const Catalog = () => { const role = subplebbit.roles[account?.author.address]?.role; if (role === 'moderator' || role === 'admin' || role === 'owner') { - setIsModerator(true); + setCanModerate(true); } else { - setIsModerator(false); + setCanModerate(false); } } - }, [account?.author.address, subplebbit.roles, setIsModerator]); + }, [account?.author.address, subplebbit.roles, setCanModerate]); useEffect(() => { setSelectedAddress(subplebbitAddress); diff --git a/src/components/views/Description.jsx b/src/components/views/Description.jsx index dd293846..130647a3 100644 --- a/src/components/views/Description.jsx +++ b/src/components/views/Description.jsx @@ -427,7 +427,7 @@ const Description = () => { style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }} >
                - {/* {isModerator ? ( + {/* {canModerate ? ( <> change description diff --git a/src/components/views/Rules.jsx b/src/components/views/Rules.jsx index 71264fc6..da47c8c5 100644 --- a/src/components/views/Rules.jsx +++ b/src/components/views/Rules.jsx @@ -412,7 +412,7 @@ const Rules = () => { >
                  - {/* {isModerator ? ( + {/* {canModerate ? ( <> change rules diff --git a/src/components/views/Subscriptions.jsx b/src/components/views/Subscriptions.jsx index 560db54b..7b3320f3 100755 --- a/src/components/views/Subscriptions.jsx +++ b/src/components/views/Subscriptions.jsx @@ -721,7 +721,7 @@ const Subscriptions = () => { const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {}; const commentMediaInfo = getCommentMediaInfo(thread); const fallbackImgUrl = 'assets/filedeleted-res.gif'; - const isModerator = moderatorPermissions[thread.subplebbitAddress]; + const canModerate = moderatorPermissions[thread.subplebbitAddress]; let displayWidth, displayHeight, displayWidthMobile, displayHeightMobile; if (thread.linkWidth && thread.linkHeight) { let scale = Math.min(1, 250 / Math.max(thread.linkWidth, thread.linkHeight)); @@ -1047,7 +1047,7 @@ const Subscriptions = () => {
                • handleAuthorDeleteClick(thread)}>Delete post
                • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
                • {
                • handleAuthorDeleteClick(reply)}>Delete post
                • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
                • {
                • handleAuthorDeleteClick(thread)}>Delete post
                • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
                • {
                • handleAuthorDeleteClick(reply)}>Delete post
                • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
                • { const [isImageSearchOpen, setIsImageSearchOpen] = useState(false); const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false); const [commentCid, setCommentCid] = useState(null); - const [isModerator, setIsModerator] = useState(false); + const [canModerate, setCanModerate] = useState(false); const [, setNewErrorMessage] = useError(); const [, setNewSuccessMessage] = useSuccess(); @@ -161,9 +161,9 @@ const CatalogPost = ({ post }) => { const role = subplebbit.roles[account?.author.address]?.role; if (role === 'moderator' || role === 'admin' || role === 'owner') { - setIsModerator(true); + setCanModerate(true); } else { - setIsModerator(false); + setCanModerate(false); } } }, [account?.author.address, subplebbit.roles]); @@ -573,7 +573,7 @@ const CatalogPost = ({ post }) => {
                • handleAuthorDeleteClick(thread)}>Delete post
                • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
                • { const [visible, setVisible] = useState(true); const [isImageSearchOpen, setIsImageSearchOpen] = useState(false); const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false); - const [isModerator, setIsModerator] = useState(false); + const [canModerate, setCanModerate] = useState(false); const [commentCid, setCommentCid] = useState(null); const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 }); const [mobileMenuPosition, setMobileMenuPosition] = useState({ top: 0, left: 0 }); @@ -200,9 +200,9 @@ const Thread = () => { const role = subplebbit.roles[account?.author?.address]?.role; if (role === 'moderator' || role === 'admin' || role === 'owner') { - setIsModerator(true); + setCanModerate(true); } else { - setIsModerator(false); + setCanModerate(false); } } }, [account?.author.address, subplebbit.roles]); @@ -1205,7 +1205,7 @@ const Thread = () => {
                • handleAuthorDeleteClick(comment)}>Delete post
                • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
                • {
                • handleAuthorDeleteClick(reply)}>Delete post
                • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
                • {
                • handleAuthorDeleteClick(comment)}>Delete post
                • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
                • {
                • handleAuthorDeleteClick(reply)}>Delete post
                • ) : null} - {isModerator ? ( + {canModerate ? ( <> {authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
                • ({ setEditedComments: (comments) => set({ editedComments: comments }), feedCacheStates: {}, - setFeedCacheState: (address, isCached) => set((prev) => ({ - feedCacheStates: { - ...prev.feedCacheStates, - [address]: isCached, - } - })), + setFeedCacheState: (address, isCached) => + set((prev) => ({ + feedCacheStates: { + ...prev.feedCacheStates, + [address]: isCached, + }, + })), isAuthorDelete: false, setIsAuthorDelete: (isAuthorDelete) => set({ isAuthorDelete }), @@ -49,8 +50,8 @@ const useGeneralStore = create((set) => ({ isEditModalOpen: false, setIsEditModalOpen: (isOpen) => set({ isEditModalOpen: isOpen }), - isModerator: false, - setIsModerator: (isModerator) => set({ isModerator }), + canModerate: false, + setCanModerate: (canModerate) => set({ canModerate }), isModerationOpen: false, setIsModerationOpen: (isOpen) => set({ isModerationOpen: isOpen }), @@ -81,7 +82,7 @@ const useGeneralStore = create((set) => ({ resolveCaptchaPromise: null, setResolveCaptchaPromise: (resolve) => set({ resolveCaptchaPromise: resolve }), - + selectedAddress: '', setSelectedAddress: (address) => set({ selectedAddress: address }), @@ -90,7 +91,7 @@ const useGeneralStore = create((set) => ({ selectedShortCid: '', setSelectedShortCid: (shortCid) => set({ selectedShortCid: shortCid }), - + selectedStyle: localStorage.getItem('selectedStyle') || 'Yotsuba', setSelectedStyle: (style) => { localStorage.setItem('selectedStyle', style); @@ -99,7 +100,7 @@ const useGeneralStore = create((set) => ({ selectedText: '', setSelectedText: (text) => set({ selectedText: text }), - + selectedThread: '', setSelectedThread: (thread) => set({ selectedThread: thread }), @@ -114,7 +115,6 @@ const useGeneralStore = create((set) => ({ triggerInsertion: 0, setTriggerInsertion: (trigger) => set({ triggerInsertion: trigger }), - })); -export default useGeneralStore; \ No newline at end of file +export default useGeneralStore; From 2d8ecaa9a07a0cb0dda7cc30639228d2ee1d570c Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 29 Sep 2023 09:24:18 +0200 Subject: [PATCH 3/9] fix(Post): remove unnecessary key property causing warning --- src/components/Post.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Post.jsx b/src/components/Post.jsx index 3750c61b..24c38bc4 100644 --- a/src/components/Post.jsx +++ b/src/components/Post.jsx @@ -81,7 +81,6 @@ const Post = ({ content, postQuoteOnClick, postQuoteOnOver, postQuoteOnLeave, po parts.push( Date: Fri, 29 Sep 2023 09:24:43 +0200 Subject: [PATCH 4/9] style(AdminListModal): fix position and margin of header --- src/components/modals/AdminListModal.jsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/modals/AdminListModal.jsx b/src/components/modals/AdminListModal.jsx index cf5518f4..c4f22971 100644 --- a/src/components/modals/AdminListModal.jsx +++ b/src/components/modals/AdminListModal.jsx @@ -44,9 +44,7 @@ const AdminListModal = ({ isOpen, closeModal, roles }) => { }} >
                From e3b577b6900ba87be0aab85745038dfe40fb6c6a Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 30 Sep 2023 10:58:55 +0200 Subject: [PATCH 8/9] fix(App.js): remove automatic dark mode, because it's not part of 4chan UX and it's not old school, and the selected style is saved anyway --- src/App.js | 331 +++++++++++++++++++++++------------------------------ 1 file changed, 142 insertions(+), 189 deletions(-) diff --git a/src/App.js b/src/App.js index e4c825ec..40a8b936 100755 --- a/src/App.js +++ b/src/App.js @@ -28,209 +28,162 @@ import packageJson from '../package.json'; const commitRef = process?.env?.REACT_APP_COMMIT_REF || ''; export default function App() { - const { - bodyStyle, - setBodyStyle, - setDefaultSubplebbits, - isCaptchaOpen, - setIsCaptchaOpen, - setIsSettingsOpen, - selectedStyle, - setSelectedStyle, - setShowPostForm, - setShowPostFormLink, - } = useGeneralStore((state) => state); + const { bodyStyle, setBodyStyle, setDefaultSubplebbits, isCaptchaOpen, setIsCaptchaOpen, setIsSettingsOpen, selectedStyle, setShowPostForm, setShowPostFormLink } = + useGeneralStore((state) => state); - const location = useLocation(); - const isHomeRoute = location.pathname === '/'; - const isElectron = window.electron && window.electron.isElectron; + const location = useLocation(); + const isElectron = window.electron && window.electron.isElectron; - const [, setNewErrorMessage] = useError(); - const [, setNewSuccessMessage] = useSuccess(); - const [, setNewInfoMessage] = useInfo(); + const [, setNewErrorMessage] = useError(); + const [, setNewSuccessMessage] = useSuccess(); + const [, setNewInfoMessage] = useInfo(); - const [infoMessageShown, setInfoMessageShown] = useState(false); + const [infoMessageShown, setInfoMessageShown] = useState(false); - useEffect(() => { - const successToast = localStorage.getItem('successToast'); - const errorToast = localStorage.getItem('errorToast'); - if (successToast) { - setNewSuccessMessage(successToast); - localStorage.removeItem('successToast'); - } else if (errorToast) { - setNewErrorMessage(errorToast); - localStorage.removeItem('errorToast'); - } else { - return; - } - }, [setNewErrorMessage, setNewSuccessMessage]); + useEffect(() => { + const successToast = localStorage.getItem('successToast'); + const errorToast = localStorage.getItem('errorToast'); + if (successToast) { + setNewSuccessMessage(successToast); + localStorage.removeItem('successToast'); + } else if (errorToast) { + setNewErrorMessage(errorToast); + localStorage.removeItem('errorToast'); + } else { + return; + } + }, [setNewErrorMessage, setNewSuccessMessage]); - // check for new version - // TODO: delete this code and toast when v1.0.0 is released - useEffect(() => { - const fetchVersionInfo = async () => { - try { - const packageRes = await fetch('https://raw.githubusercontent.com/plebbit/plebchan/master/package.json', { cache: 'no-cache' }); - const packageData = await packageRes.json(); + // check for new version + // TODO: delete this code and toast when v1.0.0 is released + useEffect(() => { + const fetchVersionInfo = async () => { + try { + const packageRes = await fetch('https://raw.githubusercontent.com/plebbit/plebchan/master/package.json', { cache: 'no-cache' }); + const packageData = await packageRes.json(); - if (packageJson.version !== packageData.version && !infoMessageShown) { - const newVersionInfo = isElectron - ? `New version available, plebchan v${packageData.version}. You are using v${packageJson.version}. Download the latest version here: https://github.com/plebbit/plebchan/releases/latest` - : `New version available, plebchan v${packageData.version}. You are using v${packageJson.version}. Refresh to update.`; - setNewInfoMessage(newVersionInfo); - setInfoMessageShown(true); - } + if (packageJson.version !== packageData.version && !infoMessageShown) { + const newVersionInfo = isElectron + ? `New version available, plebchan v${packageData.version}. You are using v${packageJson.version}. Download the latest version here: https://github.com/plebbit/plebchan/releases/latest` + : `New version available, plebchan v${packageData.version}. You are using v${packageJson.version}. Refresh to update.`; + setNewInfoMessage(newVersionInfo); + setInfoMessageShown(true); + } - if (commitRef.length > 0) { - const commitRes = await fetch('https://api.github.com/repos/plebbit/plebchan/commits?per_page=1&sha=development', { cache: 'no-cache' }); - const commitData = await commitRes.json(); + if (commitRef.length > 0) { + const commitRes = await fetch('https://api.github.com/repos/plebbit/plebchan/commits?per_page=1&sha=development', { cache: 'no-cache' }); + const commitData = await commitRes.json(); - const latestCommitHash = commitData[0].sha; + const latestCommitHash = commitData[0].sha; - if (latestCommitHash.trim() !== commitRef.trim() && !infoMessageShown) { - const newVersionInfo = `New dev version available, commit ${latestCommitHash.slice(0, 7)}. You are using commit ${commitRef.slice(0, 7)}. Refresh to update.`; - setNewInfoMessage(newVersionInfo); - setInfoMessageShown(true); - } - } - } catch (error) { - console.error('Failed to fetch latest version info:', error); - } - }; + if (latestCommitHash.trim() !== commitRef.trim() && !infoMessageShown) { + const newVersionInfo = `New dev version available, commit ${latestCommitHash.slice(0, 7)}. You are using commit ${commitRef.slice(0, 7)}. Refresh to update.`; + setNewInfoMessage(newVersionInfo); + setInfoMessageShown(true); + } + } + } catch (error) { + console.error('Failed to fetch latest version info:', error); + } + }; - fetchVersionInfo(); - }, [setNewInfoMessage, isElectron, infoMessageShown]); + fetchVersionInfo(); + }, [setNewInfoMessage, isElectron, infoMessageShown]); - // preload banners - useEffect(() => { - const loadImages = async () => { - const images = await importAll(require.context('../public/assets', true, /\.(png|jpe?g|svg)$/)); - const imageUrls = images.map((image) => image.default); - preloadImages(imageUrls); - }; + // preload banners + useEffect(() => { + const loadImages = async () => { + const images = await importAll(require.context('../public/assets', true, /\.(png|jpe?g|svg)$/)); + const imageUrls = images.map((image) => image.default); + preloadImages(imageUrls); + }; - loadImages(); - }, []); + loadImages(); + }, []); - // automatic dark mode without interefering with user's selected style - useEffect(() => { - if (isHomeRoute) return; + // fetch default subplebbits + useEffect(() => { + let didCancel = false; + fetch('https://raw.githubusercontent.com/plebbit/temporary-default-subplebbits/master/subplebbits.json', { cache: 'no-cache' }) + .then((res) => res.json()) + .then((res) => { + if (!didCancel) { + setDefaultSubplebbits(res); + } + }); + return () => { + didCancel = true; + }; + }, [setDefaultSubplebbits]); - const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)'); - const isDarkMode = darkModeMediaQuery.matches; + // handle nested routes + useEffect(() => { + const path = location.pathname; + if (path.endsWith('/post')) { + setShowPostFormLink(false); + setShowPostForm(true); + } else { + setShowPostFormLink(true); + setShowPostForm(false); + } - if (isDarkMode && !isHomeRoute) { - setSelectedStyle('Tomorrow'); - setBodyStyle({ - background: '#1d1f21 none', - color: '#c5c8c6', - fontFamily: 'Arial, Helvetica, sans-serif', - }); - localStorage.setItem('selectedStyle', 'Tomorrow'); - } + if (path.endsWith('/settings')) { + setIsSettingsOpen(true); + } else { + setIsSettingsOpen(false); + } + }, [location.pathname, setIsSettingsOpen, setShowPostForm, setShowPostFormLink]); - const darkModeListener = (e) => { - if (e.matches && !isHomeRoute) { - setSelectedStyle('Tomorrow'); - setBodyStyle({ - background: '#1d1f21 none', - color: '#c5c8c6', - fontFamily: 'Arial, Helvetica, sans-serif', - }); - localStorage.setItem('selectedStyle', 'Tomorrow'); - } - }; - - darkModeMediaQuery.addEventListener('change', darkModeListener); - - return () => { - darkModeMediaQuery.removeEventListener('change', darkModeListener); - }; - }, [isHomeRoute, setBodyStyle, setSelectedStyle]); - - // fetch default subplebbits - useEffect(() => { - let didCancel = false; - fetch('https://raw.githubusercontent.com/plebbit/temporary-default-subplebbits/master/subplebbits.json', { cache: 'no-cache' }) - .then((res) => res.json()) - .then((res) => { - if (!didCancel) { - setDefaultSubplebbits(res); - } - }); - return () => { - didCancel = true; - }; - }, [setDefaultSubplebbits]); - - // handle nested routes - useEffect(() => { - const path = location.pathname; - if (path.endsWith('/post')) { - setShowPostFormLink(false); - setShowPostForm(true); - } else { - setShowPostFormLink(true); - setShowPostForm(false); - } - - if (path.endsWith('/settings')) { - setIsSettingsOpen(true); - } else { - setIsSettingsOpen(false); - } - }, [location.pathname, setIsSettingsOpen, setShowPostForm, setShowPostFormLink]); - - return ( -
                - - - - - - - - - - - } /> - }> - } /> - } /> - - }> - } /> - } /> - - }> - } /> - } /> - - }> - } /> - - }> - } /> - - }> - } /> - - }> - } /> - - }> - } /> - - }> - } /> - - }> - } /> - - } /> - - - setIsCaptchaOpen(false)} /> -
                - ); + return ( +
                + + + + + + + + + + + } /> + }> + } /> + } /> + + }> + } /> + } /> + + }> + } /> + } /> + + }> + } /> + + }> + } /> + + }> + } /> + + }> + } /> + + }> + } /> + + }> + } /> + + }> + } /> + + } /> + + + setIsCaptchaOpen(false)} /> +
                + ); } From 548d4914bf1924e4312f5baa2773c98d027d011a Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 30 Sep 2023 13:24:11 +0200 Subject: [PATCH 9/9] fix(post form): make subject field optional, not mandatory --- src/components/views/Board.jsx | 5 ----- src/components/views/Catalog.jsx | 5 ----- 2 files changed, 10 deletions(-) diff --git a/src/components/views/Board.jsx b/src/components/views/Board.jsx index 6214f0b7..695b7583 100755 --- a/src/components/views/Board.jsx +++ b/src/components/views/Board.jsx @@ -463,11 +463,6 @@ const Board = () => { const handleSubmit = async (event) => { event.preventDefault(); - if (subjectRef.current.value === '') { - setNewErrorMessage('Subject field is mandatory'); - return; - } - setPublishCommentOptions((prevPublishCommentOptions) => ({ ...prevPublishCommentOptions, author: { diff --git a/src/components/views/Catalog.jsx b/src/components/views/Catalog.jsx index 38a5e617..0c49c6bf 100755 --- a/src/components/views/Catalog.jsx +++ b/src/components/views/Catalog.jsx @@ -1328,11 +1328,6 @@ const Catalog = () => { const handleSubmit = async (event) => { event.preventDefault(); - if (subjectRef.current.value === '') { - setNewErrorMessage('Subject field is mandatory'); - return; - } - setPublishCommentOptions((prevPublishCommentOptions) => ({ ...prevPublishCommentOptions, author: {