-
- (
-
- {stateString}
-
- )
+
+
+ (
+
+ {stateString}
- ))
- ) : null
+ )
+
);
};
diff --git a/src/components/modals/ModerationModal.jsx b/src/components/modals/ModerationModal.jsx
index 0c560045..1d03b46c 100755
--- a/src/components/modals/ModerationModal.jsx
+++ b/src/components/modals/ModerationModal.jsx
@@ -22,9 +22,9 @@ const ModerationModal = ({ isOpen, closeModal, deletePost }) => {
const comment = useComment({commentCid: moderatingCommentCid});
- const [pin, setPin] = useState(comment?.pinned);
+ const [pin, setPin] = useState(comment.pinned);
const [deleteThread, setDeleteThread] = useState(deletePost);
- const [close, setClose] = useState(comment?.locked);
+ const [close, setClose] = useState(comment.locked);
const [reason, setReason] = useState('');
const [triggerPublishCommentEdit, setTriggerPublishCommentEdit] = useState(false);
@@ -32,16 +32,24 @@ const ModerationModal = ({ isOpen, closeModal, deletePost }) => {
const [, setNewSuccessMessage] = useSuccess();
+ useEffect(() => {
+ setPin(comment.pinned);
+ setClose(comment.locked);
+ }, [comment]);
+
+
useEffect(() => {
setDeleteThread(deletePost);
}, [deletePost]);
+
useEffect(() => {
if (!isOpen) {
setDeleteThread(deletePost);
}
}, [isOpen, deletePost]);
+
const handleCloseModal = () => {
setDeleteThread(false);
closeModal();
@@ -59,7 +67,6 @@ const ModerationModal = ({ isOpen, closeModal, deletePost }) => {
const onChallenge = async (challenges, comment) => {
-
let challengeAnswers = [];
try {
diff --git a/src/components/modals/SettingsModal.jsx b/src/components/modals/SettingsModal.jsx
index fceb7528..9aee5831 100755
--- a/src/components/modals/SettingsModal.jsx
+++ b/src/components/modals/SettingsModal.jsx
@@ -2,6 +2,7 @@ import React, { useState, useEffect, useRef } from "react";
import { Link, useLocation, useNavigate } from "react-router-dom";
import Modal from "react-modal";
import { deleteAccount, deleteCaches, exportAccount, importAccount, setAccount, setActiveAccount, useAccount, useAccounts, useResolvedAuthorAddress } from "@plebbit/plebbit-react-hooks";
+import stringify from "json-stringify-pretty-compact"
import { StyledModal } from "../styled/modals/SettingsModal.styled";
import useError from "../../hooks/useError";
import useSuccess from "../../hooks/useSuccess";
@@ -74,18 +75,31 @@ const SettingsModal = ({ isOpen, closeModal }) => {
if (account) {
const fetchAccountData = async () => {
const data = await exportAccount();
- setAccountJson(data);
+ try {
+ const parsedData = JSON.parse(data);
+ setAccountJson(stringify(parsedData));
+ } catch (error) {
+ console.error("Failed to pretty-print the JSON:", error);
+ setAccountJson(data);
+ }
};
-
fetchAccountData();
}
- }, [account]);
+ }, [account]);
+
const handleAccountJsonChange = (e) => {
- setAccountJson(e.target.value);
+ try {
+ const parsedData = JSON.parse(e.target.value);
+ setAccountJson(stringify(parsedData));
+ } catch (error) {
+ console.error("Failed to pretty-print the JSON:", error);
+ setAccountJson(e.target.value);
+ }
};
+
useEffect(() => {
if (checkedENS && resolvedAddress && state === 'succeeded') {
@@ -375,7 +389,6 @@ const SettingsModal = ({ isOpen, closeModal }) => {
try {
const data = await exportAccount();
setAccountJson(data);
- setNewSuccessMessage("Account Data Reset Successfully");
} catch (error) {
setNewErrorMessage("Error resetting account data: " + error.message);
console.error(error);
@@ -503,7 +516,10 @@ const SettingsModal = ({ isOpen, closeModal }) => {
+ onChange={handleAccountJsonChange}
+ autoComplete="off"
+ autoCorrect="off"
+ spellCheck="false" />
{subplebbit?.state === "succeeded" ? (
<>
diff --git a/src/components/views/Catalog.jsx b/src/components/views/Catalog.jsx
index b65d4730..e737d9f5 100755
--- a/src/components/views/Catalog.jsx
+++ b/src/components/views/Catalog.jsx
@@ -17,6 +17,7 @@ import ImageBanner from '../ImageBanner';
import VerifiedAuthor from '../VerifiedAuthor';
import CreateBoardModal from '../modals/CreateBoardModal';
import ModerationModal from '../modals/ModerationModal';
+import BoardSettings from '../BoardSettings';
import OfflineIndicator from '../OfflineIndicator';
import SettingsModal from '../modals/SettingsModal';
import countLinks from '../../utils/countLinks';
@@ -1259,6 +1260,9 @@ const Catalog = () => {
[
{window.scrollTo(0, 0)}}>Return
]
+ {subplebbit.roles && subplebbit?.roles[account?.author?.address]?.role === "admin" ? (
+
+ ) : null}
{subplebbit.state === "succeeded" ? (
<>
diff --git a/yarn.lock b/yarn.lock
index 62e757e4..8339da6b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -9670,6 +9670,11 @@ json-stable-stringify-without-jsonify@^1.0.1:
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==
+json-stringify-pretty-compact@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/json-stringify-pretty-compact/-/json-stringify-pretty-compact-4.0.0.tgz#cf4844770bddee3cb89a6170fe4b00eee5dbf1d4"
+ integrity sha512-3CNZ2DnrpByG9Nqj6Xo8vqbjT4F6N+tb4Gb28ESAZjYZ5yqvmc56J+/kuIwkaAMOyblTQhUW7PxMkUb8Q36N3Q==
+
json-stringify-safe@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"