From 297569f3ed22c8eff252ddec334653af7ff5b830 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 1 Jul 2023 13:23:03 +0200 Subject: [PATCH 01/15] remove useLayoutEffect --- src/components/views/All.jsx | 18 +++++++++--------- src/components/views/Board.jsx | 18 +++++++++--------- src/components/views/Subscriptions.jsx | 18 +++++++++--------- src/components/views/Thread.jsx | 18 +++++++++--------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/components/views/All.jsx b/src/components/views/All.jsx index 34dd3b47..66c6d8d0 100755 --- a/src/components/views/All.jsx +++ b/src/components/views/All.jsx @@ -1,4 +1,4 @@ -import React, { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useState, useRef } from 'react'; +import React, { Fragment, useCallback, useEffect, useMemo, useState, useRef } from 'react'; import { confirmAlert } from 'react-confirm-alert'; import { createPortal } from 'react-dom'; import { Helmet } from 'react-helmet-async'; @@ -163,6 +163,14 @@ const All = () => { }, [openMenuCid, handleOutsideClick]); + useEffect(() => { + if (postOnHoverRef.current) { + const rect = postOnHoverRef.current.getBoundingClientRect(); + setPostOnHoverHeight(rect.height); + } + }, [outOfViewCid]); + + const errorString = useMemo(() => { for (const subplebbit of subplebbits) { if (subplebbit?.updatingState !== 'failed') { @@ -457,14 +465,6 @@ const All = () => { }; - useLayoutEffect(() => { - if (postOnHoverRef.current) { - const rect = postOnHoverRef.current.getBoundingClientRect(); - setPostOnHoverHeight(rect.height); - } - }, [outOfViewCid]); - - return ( <> diff --git a/src/components/views/Board.jsx b/src/components/views/Board.jsx index c645eaf4..ff9561dd 100755 --- a/src/components/views/Board.jsx +++ b/src/components/views/Board.jsx @@ -1,4 +1,4 @@ -import React, { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'; +import React, { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; import { Helmet } from 'react-helmet-async'; import { Link, useNavigate, useParams } from 'react-router-dom'; @@ -169,7 +169,14 @@ const Board = () => { document.removeEventListener('click', handleOutsideClick); }; }, [openMenuCid, handleOutsideClick]); - + + + useEffect(() => { + if (postOnHoverRef.current) { + const rect = postOnHoverRef.current.getBoundingClientRect(); + setPostOnHoverHeight(rect.height); + } + }, [outOfViewCid]); const errorString = useMemo(() => { @@ -618,13 +625,6 @@ const Board = () => { }; - useLayoutEffect(() => { - if (postOnHoverRef.current) { - const rect = postOnHoverRef.current.getBoundingClientRect(); - setPostOnHoverHeight(rect.height); - } - }, [outOfViewCid]); - return ( diff --git a/src/components/views/Subscriptions.jsx b/src/components/views/Subscriptions.jsx index a6067f87..9cd3f77f 100755 --- a/src/components/views/Subscriptions.jsx +++ b/src/components/views/Subscriptions.jsx @@ -1,4 +1,4 @@ -import React, { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useState, useRef } from 'react'; +import React, { Fragment, useCallback, useEffect, useMemo, useState, useRef } from 'react'; import { confirmAlert } from 'react-confirm-alert'; import { createPortal } from 'react-dom'; import { Helmet } from 'react-helmet-async'; @@ -161,6 +161,14 @@ const Subscriptions = () => { }; }, [openMenuCid, handleOutsideClick]); + + useEffect(() => { + if (postOnHoverRef.current) { + const rect = postOnHoverRef.current.getBoundingClientRect(); + setPostOnHoverHeight(rect.height); + } + }, [outOfViewCid]); + const errorString = useMemo(() => { for (const subplebbit of subplebbits) { @@ -458,14 +466,6 @@ const Subscriptions = () => { navigate(`/p/${selected}`); }; - - useLayoutEffect(() => { - if (postOnHoverRef.current) { - const rect = postOnHoverRef.current.getBoundingClientRect(); - setPostOnHoverHeight(rect.height); - } - }, [outOfViewCid]); - return ( <> diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index b714d8be..599e2629 100755 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; import { Helmet } from 'react-helmet-async'; import { Link, useNavigate, useParams } from 'react-router-dom'; @@ -161,6 +161,14 @@ const Thread = () => { }; }, [openMenuCid, handleOutsideClick]); + + useEffect(() => { + if (postOnHoverRef.current) { + const rect = postOnHoverRef.current.getBoundingClientRect(); + setPostOnHoverHeight(rect.height); + } + }, [outOfViewCid]); + useEffect(() => { window.scrollTo(0, 0); @@ -549,14 +557,6 @@ const Thread = () => { }; - useLayoutEffect(() => { - if (postOnHoverRef.current) { - const rect = postOnHoverRef.current.getBoundingClientRect(); - setPostOnHoverHeight(rect.height); - } - }, [outOfViewCid]); - - return ( <> From e2a95563051e46919f14f04f924c084010769cb2 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sun, 2 Jul 2023 11:45:56 +0200 Subject: [PATCH 02/15] fix plebbitOptions, improve error messages --- src/components/modals/ModerationModal.jsx | 4 +- src/components/modals/ReplyModal.jsx | 4 +- src/components/modals/SettingsModal.jsx | 48 ++++++++++++------- src/components/views/All.jsx | 4 +- src/components/views/AllCatalog.jsx | 4 +- src/components/views/Board.jsx | 8 ++-- src/components/views/Catalog.jsx | 8 ++-- src/components/views/Subscriptions.jsx | 4 +- src/components/views/SubscriptionsCatalog.jsx | 4 +- src/components/views/Thread.jsx | 6 +-- 10 files changed, 55 insertions(+), 39 deletions(-) diff --git a/src/components/modals/ModerationModal.jsx b/src/components/modals/ModerationModal.jsx index 44caad8d..296b74bc 100755 --- a/src/components/modals/ModerationModal.jsx +++ b/src/components/modals/ModerationModal.jsx @@ -63,7 +63,7 @@ const ModerationModal = ({ isOpen, closeModal, deletePost }) => { challengeAnswers = await getChallengeAnswersFromUser(challenges) } catch (error) { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); } if (challengeAnswers) { await comment.publishChallengeAnswers(challengeAnswers) @@ -113,7 +113,7 @@ const ModerationModal = ({ isOpen, closeModal, deletePost }) => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); diff --git a/src/components/modals/ReplyModal.jsx b/src/components/modals/ReplyModal.jsx index a73ed331..e185ebac 100755 --- a/src/components/modals/ReplyModal.jsx +++ b/src/components/modals/ReplyModal.jsx @@ -115,7 +115,7 @@ const ReplyModal = ({ isOpen, closeModal }) => { challengeAnswers = await getChallengeAnswersFromUser(challenges) } catch (error) { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); } if (challengeAnswers) { await comment.publishChallengeAnswers(challengeAnswers) @@ -136,7 +136,7 @@ const ReplyModal = ({ isOpen, closeModal }) => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); diff --git a/src/components/modals/SettingsModal.jsx b/src/components/modals/SettingsModal.jsx index f60d28bc..844e42ed 100755 --- a/src/components/modals/SettingsModal.jsx +++ b/src/components/modals/SettingsModal.jsx @@ -36,6 +36,17 @@ const SettingsModal = ({ isOpen, closeModal }) => { const importRef = useRef(); const nameRef = useRef(); + const defaultGatewayUrls = [ + 'https://ipfs.io', + 'https://ipfsgateway.xyz', + 'https://cloudflare-ipfs.com', + 'https://plebpubsub.live' + ]; + const defaultPubsubHttpClientsOptions = [ + 'https://pubsubprovider.xyz/api/v0', + 'https://plebpubsub.live/api/v0' + ]; + const isValidURL = (url) => { try { new URL(url); @@ -46,14 +57,26 @@ const SettingsModal = ({ isOpen, closeModal }) => { }; const handleSavePlebbitOptions = async () => { - const gatewayUrls = gatewayRef.current.value.split('\n').filter(url => url.trim()); - const ipfsClientsOptions = ipfsRef.current.value.split('\n').filter(url => url.trim()) || undefined; - const pubsubClientsOptions = pubsubRef.current.value.split('\n').filter(url => url.trim()); + let gatewayUrls = gatewayRef.current.value.split('\n').filter(url => url.trim()); + let ipfsClientsOptions = ipfsRef.current.value.split('\n').filter(url => url.trim()); + let pubsubClientsOptions = pubsubRef.current.value.split('\n').filter(url => url.trim()); + + if (!gatewayUrls.length) { + gatewayUrls = defaultGatewayUrls; + } + + if (!ipfsClientsOptions.length) { + ipfsClientsOptions = undefined; + } + + if (!pubsubClientsOptions.length) { + pubsubClientsOptions = defaultPubsubHttpClientsOptions; + } const invalidUrls = [ - ...gatewayUrls, + ...gatewayUrls || defaultGatewayUrls, ...(ipfsClientsOptions || []), - ...pubsubClientsOptions, + ...pubsubClientsOptions || defaultPubsubHttpClientsOptions, ].filter((url) => !isValidURL(url)); if (invalidUrls.length > 0) { @@ -72,7 +95,7 @@ const SettingsModal = ({ isOpen, closeModal }) => { localStorage.setItem("successToast", "Settings Saved"); window.location.reload(); } catch (error) { - setNewErrorMessage(error.message); + setNewErrorMessage(error.message); console.log(error); } }; @@ -81,13 +104,6 @@ const SettingsModal = ({ isOpen, closeModal }) => { setNewErrorMessage(null); setNewSuccessMessage(null); - const defaultGatewayUrls = [ - 'https://ipfs.io', - 'https://ipfsgateway.xyz', - 'https://cloudflare-ipfs.com' - ]; - const defaultPubsubHttpClientsOptions = ['https://pubsubprovider.xyz/api/v0']; - gatewayRef.current.value = defaultGatewayUrls.join('\n'); ipfsRef.current.value = ""; pubsubRef.current.value = defaultPubsubHttpClientsOptions.join('\n'); @@ -105,7 +121,7 @@ const SettingsModal = ({ isOpen, closeModal }) => { localStorage.setItem("successToast", "Settings Reset"); window.location.reload(); } catch (error) { - setNewErrorMessage(error.message); + setNewErrorMessage(error.message); console.log(error); } }; @@ -169,7 +185,7 @@ const SettingsModal = ({ isOpen, closeModal }) => { setNewSuccessMessage("Account Imported"); } catch (error) { - setNewErrorMessage(error.message); + setNewErrorMessage(error.message); console.log(error); } }; @@ -190,7 +206,7 @@ const SettingsModal = ({ isOpen, closeModal }) => { }}); setNewSuccessMessage("Account Name Saved"); } catch (error) { - setNewErrorMessage(error.message); + setNewErrorMessage(error.message); console.log(error); } }; diff --git a/src/components/views/All.jsx b/src/components/views/All.jsx index 66c6d8d0..5a7dea04 100755 --- a/src/components/views/All.jsx +++ b/src/components/views/All.jsx @@ -298,7 +298,7 @@ const All = () => { challengeAnswers = await getChallengeAnswersFromUser(challenges) } catch (error) { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); } if (challengeAnswers) { await comment.publishChallengeAnswers(challengeAnswers) @@ -355,7 +355,7 @@ const All = () => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); diff --git a/src/components/views/AllCatalog.jsx b/src/components/views/AllCatalog.jsx index 63fa7b1c..515b1104 100755 --- a/src/components/views/AllCatalog.jsx +++ b/src/components/views/AllCatalog.jsx @@ -160,7 +160,7 @@ const AllCatalog = () => { challengeAnswers = await getChallengeAnswersFromUser(challenges) } catch (error) { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); } if (challengeAnswers) { await comment.publishChallengeAnswers(challengeAnswers) @@ -209,7 +209,7 @@ const AllCatalog = () => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); diff --git a/src/components/views/Board.jsx b/src/components/views/Board.jsx index ff9561dd..e6a91ea5 100755 --- a/src/components/views/Board.jsx +++ b/src/components/views/Board.jsx @@ -323,7 +323,7 @@ const Board = () => { challengeAnswers = await getChallengeAnswersFromUser(challenges) } catch (error) { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); } if (challengeAnswers) { await comment.publishChallengeAnswers(challengeAnswers) @@ -344,7 +344,7 @@ const Board = () => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); @@ -497,7 +497,7 @@ const Board = () => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); @@ -620,7 +620,7 @@ const Board = () => { await unsubscribe(selectedAddress); } } catch (error) { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); } }; diff --git a/src/components/views/Catalog.jsx b/src/components/views/Catalog.jsx index 40b175cf..bba78daf 100755 --- a/src/components/views/Catalog.jsx +++ b/src/components/views/Catalog.jsx @@ -208,7 +208,7 @@ const Catalog = () => { challengeAnswers = await getChallengeAnswersFromUser(challenges) } catch (error) { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); } if (challengeAnswers) { await comment.publishChallengeAnswers(challengeAnswers) @@ -229,7 +229,7 @@ const Catalog = () => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); @@ -381,7 +381,7 @@ const Catalog = () => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); @@ -485,7 +485,7 @@ const Catalog = () => { await unsubscribe(selectedAddress); } } catch (error) { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); } }; diff --git a/src/components/views/Subscriptions.jsx b/src/components/views/Subscriptions.jsx index 9cd3f77f..c093a71d 100755 --- a/src/components/views/Subscriptions.jsx +++ b/src/components/views/Subscriptions.jsx @@ -299,7 +299,7 @@ const Subscriptions = () => { challengeAnswers = await getChallengeAnswersFromUser(challenges) } catch (error) { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); } if (challengeAnswers) { await comment.publishChallengeAnswers(challengeAnswers) @@ -349,7 +349,7 @@ const Subscriptions = () => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); diff --git a/src/components/views/SubscriptionsCatalog.jsx b/src/components/views/SubscriptionsCatalog.jsx index 34ee696a..7bbb5a3c 100755 --- a/src/components/views/SubscriptionsCatalog.jsx +++ b/src/components/views/SubscriptionsCatalog.jsx @@ -157,7 +157,7 @@ const SubscriptionsCatalog = () => { challengeAnswers = await getChallengeAnswersFromUser(challenges) } catch (error) { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); } if (challengeAnswers) { await comment.publishChallengeAnswers(challengeAnswers) @@ -206,7 +206,7 @@ const SubscriptionsCatalog = () => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index 599e2629..708a73e0 100755 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -280,7 +280,7 @@ const Thread = () => { challengeAnswers = await getChallengeAnswersFromUser(challenges) } catch (error) { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); } if (challengeAnswers) { await comment.publishChallengeAnswers(challengeAnswers) @@ -301,7 +301,7 @@ const Thread = () => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); @@ -454,7 +454,7 @@ const Thread = () => { onChallenge, onChallengeVerification, onError: (error) => { - setNewErrorMessage(error); + setNewErrorMessage(error.message); console.log(error); }, }); From 42bafa6abdf9bc62ce9c491bcf4607bd6fa87d4a Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sun, 2 Jul 2023 21:36:08 +0200 Subject: [PATCH 03/15] fix error messages, comment edits, ENS discrepancy --- src/components/modals/ModerationModal.jsx | 13 ++++++++- src/components/modals/ReplyModal.jsx | 3 +- src/components/views/All.jsx | 26 ++++++++++------- src/components/views/AllCatalog.jsx | 12 +++++--- src/components/views/Board.jsx | 28 +++++++++++-------- src/components/views/Catalog.jsx | 12 +++++--- src/components/views/Subscriptions.jsx | 26 ++++++++++------- src/components/views/SubscriptionsCatalog.jsx | 12 +++++--- src/components/views/Thread.jsx | 26 ++++++++++------- 9 files changed, 103 insertions(+), 55 deletions(-) diff --git a/src/components/modals/ModerationModal.jsx b/src/components/modals/ModerationModal.jsx index 296b74bc..9188516a 100755 --- a/src/components/modals/ModerationModal.jsx +++ b/src/components/modals/ModerationModal.jsx @@ -50,7 +50,8 @@ const ModerationModal = ({ isOpen, closeModal, deletePost }) => { if (challengeVerification.challengeSuccess === true) { setNewSuccessMessage('Challenge Success'); } else if (challengeVerification.challengeSuccess === false) { - setNewErrorMessage('Challenge Failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); + setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); + console.log('challenge failed', challengeVerification); } }; @@ -116,6 +117,16 @@ const ModerationModal = ({ isOpen, closeModal, deletePost }) => { setNewErrorMessage(error.message); console.log(error); }, }); + + + useEffect(() => { + if (selectedAddress) { + setPublishCommentEditOptions((prevOptions) => ({ + ...prevOptions, + subplebbitAddress: selectedAddress, + })); + } + }, [selectedAddress]); const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions); diff --git a/src/components/modals/ReplyModal.jsx b/src/components/modals/ReplyModal.jsx index e185ebac..15edc674 100755 --- a/src/components/modals/ReplyModal.jsx +++ b/src/components/modals/ReplyModal.jsx @@ -102,7 +102,8 @@ const ReplyModal = ({ isOpen, closeModal }) => { console.log('challenge success'); } else if (challengeVerification.challengeSuccess === false) { - setNewErrorMessage('challenge failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); + setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); + console.log('challenge failed', challengeVerification); } }; diff --git a/src/components/views/All.jsx b/src/components/views/All.jsx index 5a7dea04..e4ff28d1 100755 --- a/src/components/views/All.jsx +++ b/src/components/views/All.jsx @@ -287,7 +287,8 @@ const All = () => { setNewSuccessMessage('Challenge Success'); } else if (challengeVerification.challengeSuccess === false) { - setNewErrorMessage('Challenge Failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); + setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); + console.log('challenge failed', challengeVerification); } }; @@ -363,8 +364,8 @@ const All = () => { const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions); - const handleAuthorDeleteClick = (cid) => { - handleOptionClick(cid); + const handleAuthorDeleteClick = (comment) => { + handleOptionClick(comment.cid); confirmAlert({ customUI: ({ onClose }) => { @@ -378,9 +379,10 @@ const All = () => { onClick={() => { setIsAuthorDelete(true); setIsAuthorEdit(false); - setCommentCid(cid); setPublishCommentEditOptions(prevOptions => ({ ...prevOptions, + commentCid: comment.cid, + subplebbitAddress: comment.subplebbitAddress, deleted: true, })); setTriggerPublishCommentEdit(true); @@ -776,15 +778,17 @@ const All = () => { >
  • handleOptionClick(thread.cid)}>Hide thread
  • - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( <>
  • {handleAuthorEditClick(thread); setSelectedAddress(thread.subplebbitAddress);}}>Edit post
  • -
  • {handleAuthorDeleteClick(thread.cid); setSelectedAddress(thread.subplebbitAddress);}}>Delete post
  • +
  • {handleAuthorDeleteClick(thread); setSelectedAddress(thread.subplebbitAddress);}}>Delete post
  • ) : null} {isModerator ? ( <> - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( null ) : (
  • { @@ -1064,15 +1068,17 @@ const All = () => { >
    • handleOptionClick(reply.cid)}>Hide post
    • - {reply.author.shortAddress === account?.author.shortAddress ? ( + {reply.author.address === account?.author.address || + reply.author.address === account?.signer.address ? ( <>
    • {handleAuthorEditClick(reply); setSelectedAddress(thread.subplebbitAddress);}}>Edit post
    • -
    • {handleAuthorDeleteClick(reply.cid); setSelectedAddress(thread.subplebbitAddress);}}>Delete post
    • +
    • {handleAuthorDeleteClick(reply); setSelectedAddress(thread.subplebbitAddress);}}>Delete post
    • ) : null} {isModerator ? ( <> - {reply.author.shortAddress === account?.author.shortAddress ? ( + {reply.author.address === account?.author.address || + reply.author.address === account?.signer.address ? ( null ) : (
    • { diff --git a/src/components/views/AllCatalog.jsx b/src/components/views/AllCatalog.jsx index 515b1104..028000d9 100755 --- a/src/components/views/AllCatalog.jsx +++ b/src/components/views/AllCatalog.jsx @@ -149,7 +149,8 @@ const AllCatalog = () => { setNewSuccessMessage('Challenge Success'); } else if (challengeVerification.challengeSuccess === false) { - setNewErrorMessage('Challenge Failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); + setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); + console.log('challenge failed', challengeVerification); } }; @@ -232,9 +233,10 @@ const AllCatalog = () => { onClick={() => { setIsAuthorDelete(true); setIsAuthorEdit(false); - setCommentCid(comment.cid); setPublishCommentEditOptions(prevOptions => ({ ...prevOptions, + commentCid: comment.cid, + subplebbitAddress: comment.subplebbitAddress, deleted: true, })); setTriggerPublishCommentEdit(true); @@ -557,7 +559,8 @@ const AllCatalog = () => { >
      • handleOptionClick(thread.cid)}>Hide thread
      • - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( <>
      • handleAuthorEditClick(thread)}>Edit post
      • handleAuthorDeleteClick(thread)}>Delete post
      • @@ -565,7 +568,8 @@ const AllCatalog = () => { ) : null} {isModerator ? ( <> - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( null ) : (
      • { diff --git a/src/components/views/Board.jsx b/src/components/views/Board.jsx index e6a91ea5..572970d4 100755 --- a/src/components/views/Board.jsx +++ b/src/components/views/Board.jsx @@ -310,7 +310,8 @@ const Board = () => { } } else if (challengeVerification.challengeSuccess === false) { - setNewErrorMessage('Challenge Failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); + setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); + console.log('challenge failed', challengeVerification); } }; @@ -505,8 +506,8 @@ const Board = () => { const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions); - const handleAuthorDeleteClick = (cid) => { - handleOptionClick(cid); + const handleAuthorDeleteClick = (comment) => { + handleOptionClick(comment.cid); confirmAlert({ customUI: ({ onClose }) => { @@ -520,9 +521,10 @@ const Board = () => { onClick={() => { setIsAuthorDelete(true); setIsAuthorEdit(false); - setCommentCid(cid); setPublishCommentEditOptions(prevOptions => ({ ...prevOptions, + commentCid: comment.cid, + subplebbitAddress: comment.subplebbitAddress, deleted: true, })); setTriggerPublishCommentEdit(true); @@ -838,7 +840,7 @@ const Board = () => { {subplebbit?.state === "failed" ? ( null ) : ( - subplebbit?.state === "succeeded" ? ( + feed.length > 0 ? ( <> {subplebbit.rules ? <> @@ -1421,15 +1423,17 @@ const Board = () => { >
        • handleOptionClick(thread.cid)}>Hide thread
        • - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( <>
        • handleAuthorEditClick(thread)}>Edit post
        • -
        • handleAuthorDeleteClick(thread.cid)}>Delete post
        • +
        • handleAuthorDeleteClick(thread)}>Delete post
        • ) : null} {isModerator ? ( <> - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( null ) : (
        • { @@ -1702,15 +1706,17 @@ const Board = () => { >
          • handleOptionClick(reply.cid)}>Hide post
          • - {reply.author.shortAddress === account?.author.shortAddress ? ( + {reply.author.address === account?.author.address || + reply.author.address === account?.signer.address ? ( <>
          • handleAuthorEditClick(reply)}>Edit post
          • -
          • handleAuthorDeleteClick(reply.cid)}>Delete post
          • +
          • handleAuthorDeleteClick(reply)}>Delete post
          • ) : null} {isModerator ? ( <> - {reply.author.shortAddress === account?.author.shortAddress ? ( + {reply.author.address === account?.author.address || + reply.author.address === account?.signer.address ? ( null ) : (
          • { diff --git a/src/components/views/Catalog.jsx b/src/components/views/Catalog.jsx index bba78daf..633b6427 100755 --- a/src/components/views/Catalog.jsx +++ b/src/components/views/Catalog.jsx @@ -195,7 +195,8 @@ const Catalog = () => { } } else if (challengeVerification.challengeSuccess === false) { - setNewErrorMessage('Challenge Failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); + setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); + console.log('challenge failed', challengeVerification); } }; @@ -404,9 +405,10 @@ const Catalog = () => { onClick={() => { setIsAuthorDelete(true); setIsAuthorEdit(false); - setCommentCid(comment.cid); setPublishCommentEditOptions(prevOptions => ({ ...prevOptions, + commentCid: comment.cid, + subplebbitAddress: comment.subplebbitAddress, deleted: true, })); setTriggerPublishCommentEdit(true); @@ -1005,7 +1007,8 @@ const Catalog = () => { >
            • handleOptionClick(thread.cid)}>Hide thread
            • - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( <>
            • handleAuthorEditClick(thread)}>Edit post
            • handleAuthorDeleteClick(thread)}>Delete post
            • @@ -1013,7 +1016,8 @@ const Catalog = () => { ) : null} {isModerator ? ( <> - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( null ) : (
            • { diff --git a/src/components/views/Subscriptions.jsx b/src/components/views/Subscriptions.jsx index c093a71d..8aff1a0c 100755 --- a/src/components/views/Subscriptions.jsx +++ b/src/components/views/Subscriptions.jsx @@ -288,7 +288,8 @@ const Subscriptions = () => { setNewSuccessMessage('Challenge Success'); } else if (challengeVerification.challengeSuccess === false) { - setNewErrorMessage('Challenge Failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); + setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); + console.log('challenge failed', challengeVerification); } }; @@ -364,8 +365,8 @@ const Subscriptions = () => { const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions); - const handleAuthorDeleteClick = (cid) => { - handleOptionClick(cid); + const handleAuthorDeleteClick = (comment) => { + handleOptionClick(comment.cid); confirmAlert({ customUI: ({ onClose }) => { @@ -379,9 +380,10 @@ const Subscriptions = () => { onClick={() => { setIsAuthorDelete(true); setIsAuthorEdit(false); - setCommentCid(cid); setPublishCommentEditOptions(prevOptions => ({ ...prevOptions, + commentCid: comment.cid, + subplebbitAddress: comment.subplebbitAddress, deleted: true, })); setTriggerPublishCommentEdit(true); @@ -786,15 +788,17 @@ const Subscriptions = () => { >
              • handleOptionClick(thread.cid)}>Hide thread
              • - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( <>
              • {handleAuthorEditClick(thread); setSelectedAddress(thread.subplebbitAddress);}}>Edit post
              • -
              • {handleAuthorDeleteClick(thread.cid); setSelectedAddress(thread.subplebbitAddress);}}>Delete post
              • +
              • {handleAuthorDeleteClick(thread); setSelectedAddress(thread.subplebbitAddress);}}>Delete post
              • ) : null} {isModerator ? ( <> - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( null ) : (
              • { @@ -1074,15 +1078,17 @@ const Subscriptions = () => { >
                • handleOptionClick(reply.cid)}>Hide post
                • - {reply.author.shortAddress === account?.author.shortAddress ? ( + {reply.author.address === account?.author.address || + reply.author.address === account?.signer.address ? ( <>
                • {handleAuthorEditClick(reply); setSelectedAddress(thread.subplebbitAddress);}}>Edit post
                • -
                • {handleAuthorDeleteClick(reply.cid); setSelectedAddress(thread.subplebbitAddress);}}>Delete post
                • +
                • {handleAuthorDeleteClick(reply); setSelectedAddress(thread.subplebbitAddress);}}>Delete post
                • ) : null} {isModerator ? ( <> - {reply.author.shortAddress === account?.author.shortAddress ? ( + {reply.author.address === account?.author.address || + reply.author.address === account?.signer.address ? ( null ) : (
                • { diff --git a/src/components/views/SubscriptionsCatalog.jsx b/src/components/views/SubscriptionsCatalog.jsx index 7bbb5a3c..037debc3 100755 --- a/src/components/views/SubscriptionsCatalog.jsx +++ b/src/components/views/SubscriptionsCatalog.jsx @@ -146,7 +146,8 @@ const SubscriptionsCatalog = () => { setNewSuccessMessage('Challenge Success'); } else if (challengeVerification.challengeSuccess === false) { - setNewErrorMessage('Challenge Failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); + setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); + console.log('challenge failed', challengeVerification); } }; @@ -229,9 +230,10 @@ const SubscriptionsCatalog = () => { onClick={() => { setIsAuthorDelete(true); setIsAuthorEdit(false); - setCommentCid(comment.cid); setPublishCommentEditOptions(prevOptions => ({ ...prevOptions, + commentCid: comment.cid, + subplebbitAddress: comment.subplebbitAddress, deleted: true, })); setTriggerPublishCommentEdit(true); @@ -561,7 +563,8 @@ const SubscriptionsCatalog = () => { >
                  • handleOptionClick(thread.cid)}>Hide thread
                  • - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( <>
                  • handleAuthorEditClick(thread)}>Edit post
                  • handleAuthorDeleteClick(thread)}>Delete post
                  • @@ -569,7 +572,8 @@ const SubscriptionsCatalog = () => { ) : null} {isModerator ? ( <> - {thread.author.shortAddress === account?.author.shortAddress ? ( + {thread.author.address === account?.author.address || + thread.author.address === account?.signer.address ? ( null ) : (
                  • { diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index 708a73e0..bd3a2f17 100755 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -267,7 +267,8 @@ const Thread = () => { setNewSuccessMessage('Challenge Success'); } } else if (challengeVerification.challengeSuccess === false) { - setNewErrorMessage('Challenge Failed', {reason: challengeVerification.reason, errors: challengeVerification.errors}); + setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); + console.log('challenge failed', challengeVerification); } }; @@ -462,8 +463,8 @@ const Thread = () => { const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions); - const handleAuthorDeleteClick = (cid) => { - handleOptionClick(cid); + const handleAuthorDeleteClick = (comment) => { + handleOptionClick(comment.cid); confirmAlert({ customUI: ({ onClose }) => { @@ -477,9 +478,10 @@ const Thread = () => { onClick={() => { setIsAuthorDelete(true); setIsAuthorEdit(false); - setCommentCid(cid); setPublishCommentEditOptions(prevOptions => ({ ...prevOptions, + commentCid: comment.cid, + subplebbitAddress: comment.subplebbitAddress, deleted: true, })); setTriggerPublishCommentEdit(true); @@ -948,15 +950,17 @@ const Thread = () => { >
                    • handleOptionClick(comment.cid)}>Hide thread
                    • - {comment.author?.shortAddress === account?.author.shortAddress ? ( + {comment.author.address === account?.author.address || + comment.author.address === account?.signer.address ? ( <>
                    • handleAuthorEditClick(comment)}>Edit post
                    • -
                    • handleAuthorDeleteClick(comment.cid)}>Delete post
                    • +
                    • handleAuthorDeleteClick(comment)}>Delete post
                    • ) : null} {isModerator ? ( <> - {comment.author?.shortAddress === account?.author.shortAddress ? ( + {comment.author.address === account?.author.address || + comment.author.address === account?.signer.address ? ( null ) : (
                    • { @@ -1194,15 +1198,17 @@ const Thread = () => { >
                      • handleOptionClick(reply.cid)}>Hide post
                      • - {reply.author.shortAddress === account?.author.shortAddress ? ( + {reply.author.address === account?.author.address || + reply.author.address === account?.signer.address ? ( <>
                      • handleAuthorEditClick(reply)}>Edit post
                      • -
                      • handleAuthorDeleteClick(reply.cid)}>Delete post
                      • +
                      • handleAuthorDeleteClick(reply)}>Delete post
                      • ) : null} {isModerator ? ( <> - {reply.author.shortAddress === account?.author.shortAddress ? ( + {reply.author.address === account?.author.address || + reply.author.address === account?.signer.address ? ( null ) : (
                      • { From 7a9a31a7ed9a2e9318bb9636614ab21e5352ce0d Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Mon, 3 Jul 2023 08:53:54 +0200 Subject: [PATCH 04/15] fix undefined --- src/components/views/Thread.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index bd3a2f17..b134cec7 100755 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -950,8 +950,8 @@ const Thread = () => { >
                        • handleOptionClick(comment.cid)}>Hide thread
                        • - {comment.author.address === account?.author.address || - comment.author.address === account?.signer.address ? ( + {comment.author?.address === account?.author.address || + comment.author?.address === account?.signer.address ? ( <>
                        • handleAuthorEditClick(comment)}>Edit post
                        • handleAuthorDeleteClick(comment)}>Delete post
                        • @@ -959,8 +959,8 @@ const Thread = () => { ) : null} {isModerator ? ( <> - {comment.author.address === account?.author.address || - comment.author.address === account?.signer.address ? ( + {comment.author?.address === account?.author.address || + comment.author?.address === account?.signer.address ? ( null ) : (
                        • { From ee0788a90a86072f7d96bf219b91771c2c60fd9d Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Mon, 3 Jul 2023 15:42:34 +0200 Subject: [PATCH 05/15] add exposed flag for the electron client --- electron/preload.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/electron/preload.js b/electron/preload.js index ee5de106..80bf9917 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -38,6 +38,9 @@ const defaultPlebbitOptions = { ipfsGatewayUrls: ['http://localhost:11028'] || undefined, }; +// expose a flag to indicate that we are running in electron +contextBridge.exposeInMainWorld('electron', { isElectron: true }); + // expose plebbit-js native functions into electron's renderer contextBridge.exposeInMainWorld('plebbitJsNativeFunctions', require('@plebbit/plebbit-js').nativeFunctions.node) contextBridge.exposeInMainWorld('defaultPlebbitOptions', defaultPlebbitOptions) @@ -47,4 +50,4 @@ try { if (isDev) localStorage.debug = 'plebbit-js:*,plebbit-react-hooks:*,plebchan:*'; } catch (e) { console.log(e); -} +} \ No newline at end of file From e9377ae1aab3bd944698bf080ef04b1dd788356b Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Tue, 4 Jul 2023 13:42:19 +0200 Subject: [PATCH 06/15] add link to node stats in the settings --- electron/main.js | 42 ++++++++++--------- src/components/modals/SettingsModal.jsx | 8 +++- .../styled/modals/SettingsModal.styled.jsx | 4 ++ 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/electron/main.js b/electron/main.js index 69d1620b..66083c3c 100644 --- a/electron/main.js +++ b/electron/main.js @@ -117,15 +117,18 @@ const createMainWindow = () => { // only open valid https urls to prevent remote execution // will throw if url isn't valid const validatedUrl = new URL(originalUrl); - if (validatedUrl.protocol !== 'https:') { - throw Error(`can't open url '${originalUrl}' not https`); + let serializedUrl = ''; + + // make an exception for ipfs stats + if (validatedUrl.toString() === 'http://localhost:5001/webui/') { + serializedUrl = validatedUrl.toString(); + } else if (validatedUrl.protocol === 'https:') { + // open serialized url to prevent remote execution + serializedUrl = validatedUrl.toString(); + } else { + throw Error(`can't open url '${originalUrl}', it's not https and not the allowed http exception`); } - // do not open http protocol, not private - // do not open any other protocol, will lead to remote execution - - // open serialized url to prevent remote execution - const serializedUrl = validatedUrl.toString(); shell.openExternal(serializedUrl); } catch (e) { console.warn(e); @@ -136,7 +139,7 @@ const createMainWindow = () => { // open links (with target="_blank") in external browser // do not open links in plebchan or will lead to remote execution mainWindow.webContents.setWindowOpenHandler(({url}) => { - const originalUrl = url + const originalUrl = url; try { // do not let the user open any url with shell.openExternal // or it will lead to remote execution https://benjamin-altpeter.de/shell-openexternal-dangers/ @@ -144,25 +147,26 @@ const createMainWindow = () => { // only open valid https urls to prevent remote execution // will throw if url isn't valid const validatedUrl = new URL(originalUrl); - if (validatedUrl.protocol !== 'https:') { - throw Error(`can't open url '${originalUrl}' not https`); + let serializedUrl = ''; + + // make an exception for ipfs stats + if (validatedUrl.toString() === 'http://localhost:5001/webui/') { + serializedUrl = validatedUrl.toString(); + } else if (validatedUrl.protocol === 'https:') { + // open serialized url to prevent remote execution + serializedUrl = validatedUrl.toString(); + } else { + throw Error(`can't open url '${originalUrl}', it's not https and not the allowed http exception`); } - // do not open http protocol, not private - // do not open any other protocol, will lead to remote execution - - // open serialized url to prevent remote execution - const serializedUrl = validatedUrl.toString(); shell.openExternal(serializedUrl); - setImmediate(() => { - shell.openExternal(serializedUrl) - }) } catch (e) { console.warn(e); } - return {action: 'deny'} + return {action: 'deny'}; }) + // deny permissions like location, notifications, etc https://www.electronjs.org/docs/latest/tutorial/security#5-handle-session-permission-requests-from-remote-content mainWindow.webContents.session.setPermissionRequestHandler((webContents, permission, callback) => { // deny all permissions diff --git a/src/components/modals/SettingsModal.jsx b/src/components/modals/SettingsModal.jsx index 844e42ed..144e847d 100755 --- a/src/components/modals/SettingsModal.jsx +++ b/src/components/modals/SettingsModal.jsx @@ -223,7 +223,13 @@ const SettingsModal = ({ isOpen, closeModal }) => {
                          - v{version} + v{version} -  + {window.electron && window.electron.isElectron ? ( + + full node + + ) : (web) + } Settings diff --git a/src/components/styled/modals/SettingsModal.styled.jsx b/src/components/styled/modals/SettingsModal.styled.jsx index 094a4b5e..806afb47 100644 --- a/src/components/styled/modals/SettingsModal.styled.jsx +++ b/src/components/styled/modals/SettingsModal.styled.jsx @@ -417,4 +417,8 @@ export const StyledModal = styled(Modal)` return ''; } }} + + #node-stats { + text-decoration: none; + } `; \ No newline at end of file From 17708274a6e86ca169f4d508711c3eb51190b162 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Tue, 4 Jul 2023 13:50:21 +0200 Subject: [PATCH 07/15] remove log --- src/components/modals/ReplyModal.jsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/modals/ReplyModal.jsx b/src/components/modals/ReplyModal.jsx index 15edc674..7a72c837 100755 --- a/src/components/modals/ReplyModal.jsx +++ b/src/components/modals/ReplyModal.jsx @@ -99,9 +99,8 @@ const ReplyModal = ({ isOpen, closeModal }) => { const onChallengeVerification = (challengeVerification) => { if (challengeVerification.challengeSuccess === true) { - console.log('challenge success'); - } - else if (challengeVerification.challengeSuccess === false) { + return; + } else if (challengeVerification.challengeSuccess === false) { setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); console.log('challenge failed', challengeVerification); } From 02ce0a5474baa10c9056b63abcc250d0276e3a27 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Thu, 6 Jul 2023 10:33:01 +0200 Subject: [PATCH 08/15] fix yotsuba b --- src/components/styled/views/Board.styled.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/styled/views/Board.styled.jsx b/src/components/styled/views/Board.styled.jsx index f3ef6856..81c3b8c4 100644 --- a/src/components/styled/views/Board.styled.jsx +++ b/src/components/styled/views/Board.styled.jsx @@ -267,7 +267,7 @@ export const Header = styled.div` clear: both; .banner { - border: 1px solid #800; + border: 1px solid #34345c; margin: 5px auto; width: 300px; height: 100px; From 87fcc80898916a8de1e34cd1c3ece1b75cc4cb83 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Thu, 6 Jul 2023 13:14:20 +0200 Subject: [PATCH 09/15] fix loading state of empty feed --- src/components/views/All.jsx | 6 +++--- src/components/views/AllCatalog.jsx | 4 ++-- src/components/views/Board.jsx | 6 +++--- src/components/views/Catalog.jsx | 4 ++-- src/components/views/Subscriptions.jsx | 14 +++++++------- src/components/views/SubscriptionsCatalog.jsx | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/components/views/All.jsx b/src/components/views/All.jsx index e4ff28d1..a4a4a254 100755 --- a/src/components/views/All.jsx +++ b/src/components/views/All.jsx @@ -585,7 +585,7 @@ const All = () => { Catalog ]
                          - {feed.length > 0 ? ( + {feed ? ( null ) : (
                          @@ -601,7 +601,7 @@ const All = () => {
                          - {feed.length > 0 ? ( + {feed ? ( { }} endReached={tryLoadMore} useWindowScroll={true} - components={{ Footer: hasMore ? () => : null }} + components={{ Footer: hasMore && feed ? () => : null }} /> ) : ( diff --git a/src/components/views/AllCatalog.jsx b/src/components/views/AllCatalog.jsx index 028000d9..cf9b5a63 100755 --- a/src/components/views/AllCatalog.jsx +++ b/src/components/views/AllCatalog.jsx @@ -442,7 +442,7 @@ const AllCatalog = () => { Return
                          - {feed.length > 0 ? ( + {feed ? ( null ) : (
                          @@ -453,7 +453,7 @@ const AllCatalog = () => { - {feed.length > 0 ? ( + {feed ? ( { {window.scrollTo(0, 0)}}>Catalog ]
                          - {feed.length > 0 ? ( + {subplebbit?.state === "succeeded" ? ( <> [ @@ -840,7 +840,7 @@ const Board = () => { {subplebbit?.state === "failed" ? ( null ) : ( - feed.length > 0 ? ( + feed ? ( <> {subplebbit.rules ? <> @@ -2685,7 +2685,7 @@ const Board = () => { }} endReached={tryLoadMore} useWindowScroll={true} - components={{ Footer: hasMore && feed.length > 0 ? () => : null }} + components={{ Footer: hasMore && feed ? () => : null }} /> ) : () diff --git a/src/components/views/Catalog.jsx b/src/components/views/Catalog.jsx index 633b6427..8702120b 100755 --- a/src/components/views/Catalog.jsx +++ b/src/components/views/Catalog.jsx @@ -665,7 +665,7 @@ const Catalog = () => { {window.scrollTo(0, 0)}}>Return ]
                          - {feed.length > 0 ? ( + {feed ? ( <> [ @@ -699,7 +699,7 @@ const Catalog = () => { {subplebbit?.state === "failed" ? ( null ) : ( - feed.length > 0 ? ( + feed ? ( { setCommentCid(comment.cid); setOriginalCommentContent(comment.content); setIsEditModalOpen(true); - } - - + }; + + useEffect(() => { setPublishCommentEditOptions((prevOptions) => ({ ...prevOptions, @@ -563,7 +563,7 @@ const Subscriptions = () => {
                          <>
                          Subscriptions
                          - {feed.length < 1 ? ( + {account.subscriptions.length < 1 ? (
                          You haven't subscribed to any board yet.
                          ) : (
                          @@ -593,7 +593,7 @@ const Subscriptions = () => { Catalog ]
                          - {feed.length > 0 ? ( + {feed ? ( null ) : (
                          @@ -609,7 +609,7 @@ const Subscriptions = () => {
                          - { feed.length < 1 ? ( + { feed ? ( null ) : ( { }} endReached={tryLoadMore} useWindowScroll={true} - components={{ Footer: hasMore ? () => : null }} + components={{ Footer: hasMore && feed ? () => : null }} /> )}
                          diff --git a/src/components/views/SubscriptionsCatalog.jsx b/src/components/views/SubscriptionsCatalog.jsx index 037debc3..539f45e0 100755 --- a/src/components/views/SubscriptionsCatalog.jsx +++ b/src/components/views/SubscriptionsCatalog.jsx @@ -411,7 +411,7 @@ const SubscriptionsCatalog = () => {
                          <>
                          Subscriptions
                          - {feed.length < 1 ? ( + {account.subscriptions.length < 1 ? (
                          You haven't subscribed to any board yet.
                          ) : (
                          @@ -446,7 +446,7 @@ const SubscriptionsCatalog = () => { Return
                          - {feed.length > 0 ? ( + {feed ? ( null ) : (
                          @@ -457,7 +457,7 @@ const SubscriptionsCatalog = () => { - {feed.length > 0 ? ( + {feed ? ( Date: Thu, 6 Jul 2023 21:59:53 +0200 Subject: [PATCH 10/15] Update Subscriptions.jsx --- src/components/views/Subscriptions.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/Subscriptions.jsx b/src/components/views/Subscriptions.jsx index 867a11a0..714a72fb 100755 --- a/src/components/views/Subscriptions.jsx +++ b/src/components/views/Subscriptions.jsx @@ -563,11 +563,11 @@ const Subscriptions = () => {
                          <>
                          Subscriptions
                          - {account.subscriptions.length < 1 ? ( + {account?.subscriptions.length < 1 ? (
                          You haven't subscribed to any board yet.
                          ) : (
                          - You have subscribed to {account.subscriptions.length} board{account.subscriptions.length > 1 ? "s" : null}. + You have subscribed to {account?.subscriptions.length} board{account?.subscriptions.length > 1 ? "s" : null}.
                          )} @@ -609,7 +609,7 @@ const Subscriptions = () => {
                          - { feed ? ( + { !feed ? ( null ) : ( Date: Fri, 7 Jul 2023 17:48:24 +0200 Subject: [PATCH 11/15] add embeds: youtube, odysee, bitchute, streamable --- src/components/modals/ReplyModal.jsx | 6 +- src/components/styled/views/Board.styled.jsx | 12 +- src/components/styled/views/Thread.styled.jsx | 10 +- src/components/views/All.jsx | 289 ++++++++++++----- src/components/views/Board.jsx | 153 ++++++++- src/components/views/Pending.jsx | 293 ++++++++++++++---- src/components/views/Subscriptions.jsx | 290 ++++++++++++----- src/components/views/Thread.jsx | 263 ++++++++++++---- src/utils/getCommentMediaInfo.js | 96 ++++-- 9 files changed, 1076 insertions(+), 336 deletions(-) diff --git a/src/components/modals/ReplyModal.jsx b/src/components/modals/ReplyModal.jsx index 7a72c837..96fb2235 100755 --- a/src/components/modals/ReplyModal.jsx +++ b/src/components/modals/ReplyModal.jsx @@ -229,8 +229,10 @@ const ReplyModal = ({ isOpen, closeModal }) => { }, [selectedParentCid, anonymousMode, account]); useEffect(() => { - updateSigner(); - }, [updateSigner]); + if (anonymousMode) { + updateSigner(); + } + }, [updateSigner, anonymousMode]); useEffect(() => { diff --git a/src/components/styled/views/Board.styled.jsx b/src/components/styled/views/Board.styled.jsx index 81c3b8c4..c2cb1312 100644 --- a/src/components/styled/views/Board.styled.jsx +++ b/src/components/styled/views/Board.styled.jsx @@ -2016,6 +2016,16 @@ export const BoardForm = styled.div` } video { + width: 100%; + height: auto; + } + + iframe { + width: 100%; + height: auto; + } + + #video-thumbnail-mobile { width: 100px; } @@ -3804,7 +3814,7 @@ export const BoardForm = styled.div` color: #707070; font-weight: 700; background-color: rgb(27,28,30); - border: 1px solid #282A2E; + border: 1px solid #2D2F33; background-image: url(assets/buttonfade-dark.png); background-repeat: repeat-x; text-decoration: none; diff --git a/src/components/styled/views/Thread.styled.jsx b/src/components/styled/views/Thread.styled.jsx index 6c1f8cc2..09b9c343 100644 --- a/src/components/styled/views/Thread.styled.jsx +++ b/src/components/styled/views/Thread.styled.jsx @@ -1193,7 +1193,13 @@ export const BoardForm = styled.div` } video { - width: 100px; + width: 100%; + height: auto; + } + + iframe { + width: 100%; + height: auto; } img { @@ -2932,7 +2938,7 @@ export const BoardForm = styled.div` color: #707070; font-weight: 700; background-color: rgb(27,28,30); - border: 1px solid #282A2E; + border: 1px solid #2D2F33; background-image: url(assets/buttonfade-dark.png); background-repeat: repeat-x; text-decoration: none; diff --git a/src/components/views/All.jsx b/src/components/views/All.jsx index a4a4a254..27f960b3 100755 --- a/src/components/views/All.jsx +++ b/src/components/views/All.jsx @@ -102,6 +102,8 @@ const All = () => { const [moderatorPermissions, setModeratorPermissions] = useState({}); const [executeAnonMode, setExecuteAnonMode] = useState(false); const [cidTracker, setCidTracker] = useState({}); + const [isThumbnailClicked, setIsThumbnailClicked] = useState({}); + const [isMobileThumbnailClicked, setIsMobileThumbnailClicked] = useState({}); const setSelectedThreadCid = (cid) => { selectedThreadCidRef.current = cid; @@ -117,6 +119,20 @@ const All = () => { const stateString = useFeedStateString(subplebbits); + const handleThumbnailClick = (index, isMobile=false) => { + if (isMobile) { + setIsMobileThumbnailClicked(prevState => ({ + ...prevState, + [index]: !prevState[index], + })); + } else { + setIsThumbnailClicked(prevState => ({ + ...prevState, + [index]: !prevState[index], + })); + } + }; + useEffect(() => { let permissions = {}; @@ -618,56 +634,110 @@ const All = () => {
                          {commentMediaInfo?.url ? ( -
                          - - {commentMediaInfo?.type === "webpage" ? ( -
                          - - {thread.thumbnailUrl ? ( +
                          +
                          + Link:  + { + commentMediaInfo?.url.length > 30 ? + commentMediaInfo?.url.slice(0, 30) + "(...)" : + commentMediaInfo?.url + } ({commentMediaInfo?.type === "iframe" ? "video" : commentMediaInfo?.type}) + {isThumbnailClicked[index] ? ( + + -[ + {handleThumbnailClick(index)}}>Close + ] + + ) : null} +
                          + {commentMediaInfo?.type === 'iframe' && ( +
                          + + {(isThumbnailClicked[index] || !commentMediaInfo.thumbnail) && commentMediaInfo.embedUrl ? ( +