diff --git a/src/components/modals/AdminListModal.jsx b/src/components/modals/AdminListModal.jsx index 1b598878..cf5518f4 100644 --- a/src/components/modals/AdminListModal.jsx +++ b/src/components/modals/AdminListModal.jsx @@ -3,23 +3,15 @@ import Modal from 'react-modal'; import Draggable from 'react-draggable'; import { StyledModal } from '../styled/modals/ReplyModal.styled'; import useGeneralStore from '../../hooks/stores/useGeneralStore'; -import { BoardForm } from '../styled/views/Board.styled' +import { BoardForm } from '../styled/views/Board.styled'; import { Link } from 'react-router-dom'; - - const AdminListModal = ({ isOpen, closeModal, roles }) => { - const { - selectedAddress, - selectedStyle, - selectedTitle, - } = useGeneralStore(state => state); + const { selectedStyle } = useGeneralStore((state) => state); const [isMobile, setIsMobile] = useState(window.innerWidth <= 480); const nodeRef = useRef(null); - const rolesList = roles - ? Object.entries(roles).map(([address, { role }]) => ({ address, role })) - : []; + const rolesList = roles ? Object.entries(roles).map(([address, { role }]) => ({ address, role })) : []; useEffect(() => { const handleResize = () => setIsMobile(window.innerWidth <= 480); @@ -30,45 +22,53 @@ const AdminListModal = ({ isOpen, closeModal, roles }) => { window.removeEventListener('resize', handleResize); }; }, [setIsMobile]); - return ( - -
-
- Admins for {selectedTitle ?? selectedAddress} -
-
+ +
- - {rolesList.map(({ address, role }, index) => ( -

- • {}} className="quote-link">u/{address}: {role} -

- ))} + maxHeight: '250px', + }} + > +
@@ -79,4 +79,4 @@ const AdminListModal = ({ isOpen, closeModal, roles }) => { Modal.setAppElement('#root'); -export default AdminListModal; \ No newline at end of file +export default AdminListModal; diff --git a/src/components/styled/views/Board.styled.jsx b/src/components/styled/views/Board.styled.jsx index 74c1a05e..c6006627 100644 --- a/src/components/styled/views/Board.styled.jsx +++ b/src/components/styled/views/Board.styled.jsx @@ -15,7 +15,8 @@ export const Container = styled.div` export const NavBar = styled.div` @media (min-width: 480px) { - .board-select, .page-jump { + .board-select, + .page-jump { display: none; } @@ -33,7 +34,8 @@ export const NavBar = styled.div` } @media (max-width: 480px) { - .boardList, .nav { + .boardList, + .nav { display: none; } @@ -81,9 +83,9 @@ export const NavBar = styled.div` } ${({ selectedStyle }) => { - switch (selectedStyle) { - case 'Yotsuba': - return `font-size: 9pt; + switch (selectedStyle) { + case 'Yotsuba': + return `font-size: 9pt; color: #b86; a, #button-span { @@ -110,8 +112,8 @@ export const NavBar = styled.div` color: navy; }`; - case 'Yotsuba-B': - return `font-size: 9pt; + case 'Yotsuba-B': + return `font-size: 9pt; color: #89a; a, #button-span { @@ -220,11 +222,12 @@ export const NavBar = styled.div` background-color: #ddd; border-bottom: 2px solid #ccc; }`; - - default: - return ''; - } - }}`; + + default: + return ''; + } + }} +`; export const Header = styled.div` ${({ selectedStyle }) => { @@ -418,10 +421,10 @@ export const Header = styled.div` margin-top: 5px; font-size: 9pt; }`; - - default: - return ''; - } + + default: + return ''; + } }} .offline { @@ -463,16 +466,16 @@ export const Break = styled.hr` border: none; border-top: 1px solid #ddd; height: 0;`; - - default: - return ''; - } + + default: + return ''; + } }} `; export const PostFormLink = styled.div` @media (min-width: 480px) { - display: ${props => (props.showPostFormLink ? 'block' : 'none')}; + display: ${(props) => (props.showPostFormLink ? 'block' : 'none')}; #post-form-link-mobile { display: none; @@ -480,7 +483,7 @@ export const PostFormLink = styled.div` } @media (max-width: 480px) { - display: ${props => (props.showPostFormLink ? 'block' : 'none')}; + display: ${(props) => (props.showPostFormLink ? 'block' : 'none')}; line-height: 30px; #post-form-link-desktop { @@ -488,11 +491,11 @@ export const PostFormLink = styled.div` } #post-form-link-mobile { - margin: 11px 0; - font-size: 10pt; - text-align: center; - font-weight: 700; - display: block !important; + margin: 11px 0; + font-size: 10pt; + text-align: center; + font-weight: 700; + display: block !important; } } @@ -620,15 +623,15 @@ export const PostFormLink = styled.div` color: #333 !important; white-space: nowrap; }`; - - default: - return ''; - } - }} + + default: + return ''; + } + }} `; export const PostFormTable = styled.table` - display: ${props => (props.showPostForm ? 'table' : 'none')}; + display: ${(props) => (props.showPostForm ? 'table' : 'none')}; width: 418px; border-spacing: 1px; margin-left: auto; @@ -1145,15 +1148,15 @@ export const PostFormTable = styled.table` width: 100% } }`; - - default: - return ''; - } + + default: + return ''; + } }} #t-help { margin: 0; - margin-top: -5px + margin-top: -5px; } `; @@ -1249,10 +1252,10 @@ export const PostForm = styled.div` a:hover { color: #ff3300; }`; - - default: - return ''; - } + + default: + return ''; + } }} `; @@ -1396,10 +1399,10 @@ export const TopBar = styled.div` a:hover, #subscribe:hover { color: #ff3300 !important; }`; - - default: - return ''; - } + + default: + return ''; + } }} .ellipsis { @@ -1407,10 +1410,10 @@ export const TopBar = styled.div` } .ellipsis:after { - content: "\\2026"; + content: '\\2026'; position: absolute; - -webkit-animation: ellipsis steps(4,end) 1200ms infinite; - animation: ellipsis steps(4,end) 1500ms infinite; + -webkit-animation: ellipsis steps(4, end) 1200ms infinite; + animation: ellipsis steps(4, end) 1500ms infinite; width: 0px; overflow: hidden; } @@ -1441,7 +1444,7 @@ export const TopBar = styled.div` max-width: calc(100vw - 50vw); word-wrap: break-word; white-space: nowrap; - text-overflow: ""; + text-overflow: ''; overflow: hidden; } @@ -1450,10 +1453,10 @@ export const TopBar = styled.div` } .ellipsis-all:after { - content: "\\2026"; + content: '\\2026'; position: absolute; - -webkit-animation: ellipsis steps(4,end) 1200ms infinite; - animation: ellipsis steps(4,end) 1500ms infinite; + -webkit-animation: ellipsis steps(4, end) 1200ms infinite; + animation: ellipsis steps(4, end) 1500ms infinite; width: 0px; overflow: hidden; } @@ -1494,7 +1497,7 @@ export const TopBar = styled.div` max-width: 90vw; word-wrap: break-word; white-space: nowrap; - text-overflow: ""; + text-overflow: ''; overflow: hidden; } @@ -1503,10 +1506,10 @@ export const TopBar = styled.div` } .ellipsis-all:after { - content: "\\2026"; + content: '\\2026'; position: absolute; - -webkit-animation: ellipsis steps(4,end) 1200ms infinite; - animation: ellipsis steps(4,end) 1500ms infinite; + -webkit-animation: ellipsis steps(4, end) 1200ms infinite; + animation: ellipsis steps(4, end) 1500ms infinite; width: 0px; overflow: hidden; } @@ -1683,11 +1686,11 @@ export const TopBar = styled.div` color: #333 !important; white-space: nowrap; }`; - - default: - return ''; - } - }} + + default: + return ''; + } + }} `; export const BoardForm = styled.div` @@ -1695,11 +1698,15 @@ export const BoardForm = styled.div` margin-right: 14px; } + .capcode-admin { + color: red !important; + } + .ellipsis:after { - content: "\\2026"; + content: '\\2026'; position: absolute; - -webkit-animation: ellipsis steps(4,end) 1200ms infinite; - animation: ellipsis steps(4,end) 1500ms infinite; + -webkit-animation: ellipsis steps(4, end) 1200ms infinite; + animation: ellipsis steps(4, end) 1500ms infinite; width: 0px; overflow: hidden; } @@ -1793,9 +1800,9 @@ export const BoardForm = styled.div` } ${({ selectedStyle }) => { - switch (selectedStyle) { - case 'Yotsuba': - return `.highlighted, .highlighted-click, .highlighted-address { + switch (selectedStyle) { + case 'Yotsuba': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #f0c0b0 !important; border: 1px solid #d99f91 !important; border-left: none !important; @@ -1821,8 +1828,8 @@ export const BoardForm = styled.div` } }`; - case 'Yotsuba-B': - return `.highlighted, .highlighted-click, .highlighted-address { + case 'Yotsuba-B': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #d6bad0 !important; border: 1px solid #ba9dbf !important; border-left: none !important; @@ -1848,8 +1855,8 @@ export const BoardForm = styled.div` } }`; - case 'Futaba': - return `.highlighted, .highlighted-click, .highlighted-address { + case 'Futaba': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #f0c0b0 !important; } @@ -1872,8 +1879,8 @@ export const BoardForm = styled.div` } }`; - case 'Burichan': - return `.highlighted, .highlighted-click, .highlighted-address { + case 'Burichan': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #d6bad0 !important; } @@ -1896,8 +1903,8 @@ export const BoardForm = styled.div` } }`; - case 'Tomorrow': - return `.highlighted, .highlighted-click, .highlighted-address { + case 'Tomorrow': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #1d1d21 !important; outline: 1px solid #111 !important; } @@ -1920,8 +1927,8 @@ export const BoardForm = styled.div` } }`; - case 'Photon': - return `.highlighted, .highlighted-click, .highlighted-address { + case 'Photon': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #ccc !important; outline: 1px solid #ccc !important; } @@ -1944,25 +1951,24 @@ export const BoardForm = styled.div` } }`; - default: return ''; } }} } - + .file { display: block; - + .file-text { max-width: 600px; white-space: nowrap; } - + .fileText a { text-decoration: underline; } - + .file-thumb { float: left; margin: 3px 20px 5px 20px; @@ -2028,7 +2034,7 @@ export const BoardForm = styled.div` margin: 4px 0; overflow: hidden; } - + .post-info-mobile { overflow: hidden; padding: 5px; @@ -2036,7 +2042,7 @@ export const BoardForm = styled.div` display: block; clear: left; } - + .post-menu-button-mobile { line-height: 1em !important; width: 1em !important; @@ -2047,14 +2053,14 @@ export const BoardForm = styled.div` float: left !important; font-weight: 700 !important; opacity: 1 !important; - height: .5em !important; + height: 0.5em !important; font-size: 16px !important; } - + .name-block-mobile { clear: none; float: left; - + .subject-mobile { display: block; } @@ -2064,7 +2070,7 @@ export const BoardForm = styled.div` float: right; text-align: right; } - + .file-mobile { display: block; @@ -2099,7 +2105,7 @@ export const BoardForm = styled.div` #video-thumbnail-mobile { width: 100px; } - + img { border: none; float: left; @@ -2108,13 +2114,13 @@ export const BoardForm = styled.div` object-fit: scale-down; margin: 0; } - + blockquote { padding-top: 5px; display: block; margin: 10px !important; } - + .post-link-mobile { clear: both !important; padding: 5px; @@ -2122,12 +2128,12 @@ export const BoardForm = styled.div` margin: -5px; display: block !important; } - + .info-mobile { margin-top: 8px; float: left; } - + .button-mobile { float: right; border-radius: 3px; @@ -2164,7 +2170,7 @@ export const BoardForm = styled.div` .file-mobile { display: block; - + .file-thumb-mobile { margin-left: 10px !important; margin-right: 10px !important; @@ -2173,7 +2179,7 @@ export const BoardForm = styled.div` margin-bottom: 5px; margin-top: 15px; } - + .file-info-mobile { padding-top: 5px; text-align: center; @@ -2186,7 +2192,7 @@ export const BoardForm = styled.div` video { max-width: 100px; } - + img { border: none; float: left; @@ -2207,12 +2213,12 @@ export const BoardForm = styled.div` width: 1em !important; text-align: center !important; outline: none !important; - transform: rotate(90deg)!important; + transform: rotate(90deg) !important; margin: 4px -5px 0 4px !important; float: left !important; font-weight: 700 !important; opacity: 1 !important; - height: .5em !important; + height: 0.5em !important; font-size: 16px !important; } @@ -2225,7 +2231,8 @@ export const BoardForm = styled.div` float: right; text-align: right; - a, #reply-button { + a, + #reply-button { text-decoration: none; } } @@ -2236,7 +2243,6 @@ export const BoardForm = styled.div` margin: 10px !important; } } - } ${({ selectedStyle }) => { @@ -3283,10 +3289,10 @@ export const BoardForm = styled.div` border-top: 1px solid #ddd; height: 0; }`; - - default: - return ''; - } + + default: + return ''; + } }} @media (max-width: 480px) { @@ -3309,7 +3315,7 @@ export const BoardForm = styled.div` margin-left: calc((100% - 100vw) / 2); margin-right: calc((100% - 100vw) / 2); } - + .name-block { display: block; } @@ -3355,7 +3361,7 @@ export const BoardForm = styled.div` return `.highlighted, .highlighted-click, .highlighted-address { background-color: #ccc !important; }`; - + default: return ''; } @@ -4078,7 +4084,7 @@ export const BoardForm = styled.div` } } }`; - + default: return ''; } @@ -4090,15 +4096,14 @@ export const PostMenu = styled.div` display: inline-block; cursor: pointer; transition: transform 0.1s; - transform: ${props => props.rotated ? 'rotate(90deg)' : 'none'}; + transform: ${(props) => (props.rotated ? 'rotate(90deg)' : 'none')}; `; export const PostMenuMobile = styled.div` - font-size: 16px; - line-height: 2.5em; - width: 216px; + font-size: 16px; + line-height: 2.5em; + width: 216px; - ul { border-right-width: 2px !important; list-style: none; @@ -4115,9 +4120,9 @@ export const PostMenuMobile = styled.div` } ${({ selectedStyle }) => { - switch (selectedStyle) { - case 'Yotsuba': - return ` + switch (selectedStyle) { + case 'Yotsuba': + return ` ul { border: 1px solid #d9bfb7; } @@ -4133,8 +4138,8 @@ export const PostMenuMobile = styled.div` } `; - case 'Yotsuba-B': - return ` + case 'Yotsuba-B': + return ` ul { border: 1px solid #b7c5d9; } @@ -4150,8 +4155,8 @@ export const PostMenuMobile = styled.div` } `; - case 'Futaba': - return ` + case 'Futaba': + return ` ul { border: 1px solid #d9bfb7; } @@ -4167,8 +4172,8 @@ export const PostMenuMobile = styled.div` } `; - case 'Burichan': - return ` + case 'Burichan': + return ` ul { border: 1px solid #b7c5d9; } @@ -4184,8 +4189,8 @@ export const PostMenuMobile = styled.div` } `; - case 'Tomorrow': - return ` + case 'Tomorrow': + return ` ul { border: 1px solid #282a2e; } @@ -4200,8 +4205,8 @@ export const PostMenuMobile = styled.div` } `; - case 'Photon': - return ` + case 'Photon': + return ` ul { border: 1px solid #ccc; } @@ -4215,9 +4220,9 @@ export const PostMenuMobile = styled.div` } } `; - - default: - return ''; - }} + + default: + return ''; } -`; \ No newline at end of file + }} +`; diff --git a/src/components/styled/views/Thread.styled.jsx b/src/components/styled/views/Thread.styled.jsx index 7b3e54af..184533df 100644 --- a/src/components/styled/views/Thread.styled.jsx +++ b/src/components/styled/views/Thread.styled.jsx @@ -2,15 +2,17 @@ import styled from 'styled-components'; export const ReplyFormLink = styled.div` @media (min-width: 480px) { - display: ${props => (props.showReplyFormLink ? 'block' : 'none')}; + display: ${(props) => (props.showReplyFormLink ? 'block' : 'none')}; - #post-form-link-mobile, #return-button-mobile, #catalog-button-mobile, #bottom-button-mobile { + #post-form-link-mobile, + #return-button-mobile, + #catalog-button-mobile, + #bottom-button-mobile { display: none; } } @media (max-width: 480px) { - #post-form-link-desktop { display: none; } @@ -24,7 +26,10 @@ export const ReplyFormLink = styled.div` padding-top: 10px; } - #return-button-mobile, #catalog-button-mobile, #bottom-button-mobile, #bottom-bar-top { + #return-button-mobile, + #catalog-button-mobile, + #bottom-button-mobile, + #bottom-bar-top { font-size: 10pt; display: inline-block; margin: 0 2px; @@ -164,11 +169,11 @@ export const ReplyFormLink = styled.div` color: #333 !important; white-space: nowrap; }`; - + default: return ''; - } - }} + } + }} `; export const TopBar = styled.div` @@ -186,7 +191,7 @@ export const TopBar = styled.div` max-width: calc(100vw - 50vw); word-wrap: break-word; white-space: nowrap; - text-overflow: ""; + text-overflow: ''; overflow: hidden; } @@ -195,10 +200,10 @@ export const TopBar = styled.div` } .ellipsis-all:after { - content: "\\2026"; + content: '\\2026'; position: absolute; - -webkit-animation: ellipsis steps(4,end) 1200ms infinite; - animation: ellipsis steps(4,end) 1500ms infinite; + -webkit-animation: ellipsis steps(4, end) 1200ms infinite; + animation: ellipsis steps(4, end) 1500ms infinite; width: 0px; overflow: hidden; } @@ -223,7 +228,7 @@ export const TopBar = styled.div` } @media (max-width: 480px) { - .stats-all-catalog-container { + .stats-all-catalog-container { height: 25px; position: absolute; text-align: left; @@ -237,7 +242,7 @@ export const TopBar = styled.div` max-width: 90vw; word-wrap: break-word; white-space: nowrap; - text-overflow: ""; + text-overflow: ''; overflow: hidden; } @@ -246,17 +251,19 @@ export const TopBar = styled.div` } .ellipsis-all:after { - content: "\\2026"; + content: '\\2026'; position: absolute; - -webkit-animation: ellipsis steps(4,end) 1200ms infinite; - animation: ellipsis steps(4,end) 1500ms infinite; + -webkit-animation: ellipsis steps(4, end) 1200ms infinite; + animation: ellipsis steps(4, end) 1500ms infinite; width: 0px; overflow: hidden; } - + line-height: 30px; - - #return-button-desktop, #catalog-button-desktop, #bottom-button-desktop { + + #return-button-desktop, + #catalog-button-desktop, + #bottom-button-desktop { display: none; } @@ -293,10 +300,10 @@ export const TopBar = styled.div` } .ellipsis:after { - content: "\\2026"; + content: '\\2026'; position: absolute; - -webkit-animation: ellipsis steps(4,end) 1200ms infinite; - animation: ellipsis steps(4,end) 1500ms infinite; + -webkit-animation: ellipsis steps(4, end) 1200ms infinite; + animation: ellipsis steps(4, end) 1500ms infinite; width: 0px; overflow: hidden; } @@ -317,7 +324,7 @@ export const TopBar = styled.div` display: inline-block; } - .reply-stat { + .reply-stat { position: relative; float: right; margin-right: 5px; @@ -696,11 +703,11 @@ export const TopBar = styled.div` color: #333 !important; white-space: nowrap; }`; - - default: - return ''; - } - }} + + default: + return ''; + } + }} `; export const BottomBar = styled.div` @@ -709,10 +716,10 @@ export const BottomBar = styled.div` } .ellipsis:after { - content: "\\2026"; + content: '\\2026'; position: absolute; - -webkit-animation: ellipsis steps(4,end) 1200ms infinite; - animation: ellipsis steps(4,end) 1500ms infinite; + -webkit-animation: ellipsis steps(4, end) 1200ms infinite; + animation: ellipsis steps(4, end) 1500ms infinite; width: 0px; overflow: hidden; } @@ -729,7 +736,7 @@ export const BottomBar = styled.div` } } - .reply-stat { + .reply-stat { position: relative; float: right; margin-right: 5px; @@ -899,11 +906,15 @@ export const BoardForm = styled.div` margin-right: 14px; } + .capcode-admin { + color: red !important; + } + .ellipsis:after { - content: "\\2026"; + content: '\\2026'; position: absolute; - -webkit-animation: ellipsis steps(4,end) 1200ms infinite; - animation: ellipsis steps(4,end) 1500ms infinite; + -webkit-animation: ellipsis steps(4, end) 1200ms infinite; + animation: ellipsis steps(4, end) 1500ms infinite; width: 0px; overflow: hidden; } @@ -982,9 +993,9 @@ export const BoardForm = styled.div` } ${({ selectedStyle }) => { - switch (selectedStyle) { - case 'Yotsuba': - return `.highlighted, .highlighted-click, .highlighted-address { + switch (selectedStyle) { + case 'Yotsuba': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #f0c0b0 !important; border: 1px solid #d99f91 !important; border-left: none !important; @@ -1008,8 +1019,8 @@ export const BoardForm = styled.div` } }`; - case 'Yotsuba-B': - return `.highlighted, .highlighted-click, .highlighted-address { + case 'Yotsuba-B': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #d6bad0 !important; border: 1px solid #ba9dbf !important; border-left: none !important; @@ -1032,8 +1043,8 @@ export const BoardForm = styled.div` } }`; - case 'Futaba': - return `.highlighted, .highlighted-click, .highlighted-address { + case 'Futaba': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #f0c0b0 !important; } @@ -1055,8 +1066,8 @@ export const BoardForm = styled.div` } }`; - case 'Burichan': - return `.highlighted, .highlighted-click, .highlighted-address { + case 'Burichan': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #d6bad0 !important; } @@ -1078,8 +1089,8 @@ export const BoardForm = styled.div` } }`; - case 'Tomorrow': - return `.highlighted, .highlighted-click, .highlighted-address { + case 'Tomorrow': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #1d1d21 !important; outline: 1px solid #111 !important; } @@ -1100,8 +1111,8 @@ export const BoardForm = styled.div` } }`; - case 'Photon': - return `.highlighted, .highlighted-click, .highlighted-address { + case 'Photon': + return `.highlighted, .highlighted-click, .highlighted-address { background-color: #ccc !important; outline: 1px solid #ccc !important; } @@ -1127,19 +1138,19 @@ export const BoardForm = styled.div` } }} } - + .file { display: block; - + .file-text { max-width: 600px; white-space: nowrap; } - + .fileText a { text-decoration: underline; } - + .file-thumb { float: left; margin: 3px 20px 5px 20px; @@ -1155,7 +1166,7 @@ export const BoardForm = styled.div` float: left; margin: 3px 20px 5px 20px; } - + .file-thumb img, .file-thumb video, .file-thumb audio { @@ -1170,7 +1181,6 @@ export const BoardForm = styled.div` max-width: 125px; max-height: 125px; } - } .thread-mobile { @@ -1194,7 +1204,7 @@ export const BoardForm = styled.div` margin: 4px 0; overflow: hidden; } - + .post-info-mobile { overflow: hidden; padding: 5px; @@ -1202,7 +1212,7 @@ export const BoardForm = styled.div` display: block; clear: left; } - + .post-menu-button-mobile { line-height: 1em !important; width: 1em !important; @@ -1213,14 +1223,14 @@ export const BoardForm = styled.div` float: left !important; font-weight: 700 !important; opacity: 1 !important; - height: .5em !important; + height: 0.5em !important; font-size: 16px !important; } - + .name-block-mobile { clear: none; float: left; - + .subject-mobile { display: block; } @@ -1230,10 +1240,10 @@ export const BoardForm = styled.div` float: right; text-align: right; } - + .file-mobile { display: block; - + .file-thumb-mobile { margin-left: 10px !important; margin-right: 10px !important; @@ -1242,7 +1252,7 @@ export const BoardForm = styled.div` margin-bottom: 5px; margin-top: 15px; } - + .file-info-mobile { padding-top: 5px; text-align: center; @@ -1250,7 +1260,6 @@ export const BoardForm = styled.div` display: block !important; clear: left !important; } - } video { @@ -1262,7 +1271,7 @@ export const BoardForm = styled.div` width: 100%; height: auto; } - + img { border: none; float: left; @@ -1270,13 +1279,13 @@ export const BoardForm = styled.div` max-height: 100px; object-fit: scale-down; } - + blockquote { padding-top: 5px; display: block; margin: 10px !important; } - + .post-link-mobile { clear: both !important; padding: 5px; @@ -1284,12 +1293,12 @@ export const BoardForm = styled.div` margin: -5px; display: block !important; } - + .info-mobile { margin-top: 8px; float: left; } - + .button-mobile { float: right; border-radius: 3px; @@ -1313,7 +1322,7 @@ export const BoardForm = styled.div` .file-mobile { display: block; - + .file-thumb-mobile { margin-left: 10px !important; margin-right: 10px !important; @@ -1322,7 +1331,7 @@ export const BoardForm = styled.div` margin-bottom: 5px; margin-top: 15px; } - + .file-info-mobile { padding-top: 5px; text-align: center; @@ -1335,7 +1344,7 @@ export const BoardForm = styled.div` video { max-width: 100px; } - + img { border: none; float: left; @@ -1356,12 +1365,12 @@ export const BoardForm = styled.div` width: 1em !important; text-align: center !important; outline: none !important; - transform: rotate(90deg)!important; + transform: rotate(90deg) !important; margin: 4px -5px 0 4px !important; float: left !important; font-weight: 700 !important; opacity: 1 !important; - height: .5em !important; + height: 0.5em !important; font-size: 16px !important; } @@ -1385,7 +1394,6 @@ export const BoardForm = styled.div` margin: 10px !important; } } - } ${({ selectedStyle }) => { @@ -2421,7 +2429,7 @@ export const BoardForm = styled.div` margin-left: calc((100% - 100vw) / 2); margin-right: calc((100% - 100vw) / 2); } - + .name-block { display: block; } @@ -2467,10 +2475,10 @@ export const BoardForm = styled.div` return `.highlighted, .highlighted-click, .highlighted-address { background-color: #ccc !important; }`; - - default: - return ''; - } + + default: + return ''; + } }} ${({ selectedStyle }) => { @@ -3195,7 +3203,7 @@ export const BoardForm = styled.div` } } }`; - + default: return ''; } @@ -3207,7 +3215,7 @@ export const Footer = styled.div` #version { text-align: center; font-size: 11px; - font-family: "arial"; + font-family: 'arial'; } @media (min-width: 480px) { #break { @@ -3319,9 +3327,9 @@ export const Footer = styled.div` color: #f30; } }`; - - default: - return ''; - } + + default: + return ''; + } }} -`; \ No newline at end of file +`; diff --git a/src/components/views/All.jsx b/src/components/views/All.jsx index ba49d68d..b1c78214 100755 --- a/src/components/views/All.jsx +++ b/src/components/views/All.jsx @@ -915,7 +915,7 @@ const All = () => { Anonymous )} -   (u/ +  (u/ { setIsAdminListOpen(!isAdminListOpen); }} > - ## Board Admins + ## Board Mods   { )} { setIsAdminListOpen(!isAdminListOpen); }} > - ## Board Admins + ## Board Mods   @@ -1215,7 +1215,7 @@ const Board = () => { setIsAdminListOpen(!isAdminListOpen); }} > - ## Board Admins + ## Board Mods   { )} { setIsAdminListOpen(!isAdminListOpen); }} > - ## Board Admins + ## Board Mods   @@ -1457,7 +1457,7 @@ const Board = () => { setIsAdminListOpen(!isAdminListOpen); }} > - ## Board Admins + ## Board Mods   { )} { setIsAdminListOpen(!isAdminListOpen); }} > - ## Board Admins + ## Board Mods   @@ -1941,7 +1941,7 @@ const Board = () => { Anonymous )} -   (u/ +  (u/ { )} - )   + )  { - const { - editedComment, - setDeletePost, - setIsAuthorDelete, - captchaResponse, - setCaptchaResponse, - selectedAddress, - setIsModerationOpen, - setChallengesArray, - setIsAuthorEdit, - setIsCaptchaOpen, - setIsEditModalOpen, - isModerator, - setModeratingCommentCid, - setOriginalCommentContent, - setPendingComment, - setResolveCaptchaPromise, - selectedStyle, - setSelectedThread, - } = useGeneralStore((state) => state); + const { + editedComment, + setDeletePost, + setIsAuthorDelete, + captchaResponse, + setCaptchaResponse, + selectedAddress, + setIsModerationOpen, + setChallengesArray, + setIsAuthorEdit, + setIsCaptchaOpen, + setIsEditModalOpen, + isModerator, + setModeratingCommentCid, + setOriginalCommentContent, + setPendingComment, + setResolveCaptchaPromise, + selectedStyle, + setSelectedThread, + } = useGeneralStore((state) => state); - const thread = post; - const commentMediaInfo = getCommentMediaInfo(thread); - const linkCount = countLinks(thread); - const fallbackImgUrl = 'assets/filedeleted-res.gif'; - const [isHoveringOnThread, setIsHoveringOnThread] = useState(false); - const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 }); - const [popupPosition, setPopupPosition] = useState({ top: 0, left: 0 }); - const [openMenuCid, setOpenMenuCid] = useState(null); - const [triggerPublishCommentEdit, setTriggerPublishCommentEdit] = useState(false); - const [isImageSearchOpen, setIsImageSearchOpen] = useState(false); - const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false); - const [commentCid, setCommentCid] = useState(null); + const thread = post; + const commentMediaInfo = getCommentMediaInfo(thread); + const linkCount = countLinks(thread); + const fallbackImgUrl = 'assets/filedeleted-res.gif'; + const [isHoveringOnThread, setIsHoveringOnThread] = useState(false); + const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 }); + const [popupPosition, setPopupPosition] = useState({ top: 0, left: 0 }); + const [openMenuCid, setOpenMenuCid] = useState(null); + const [triggerPublishCommentEdit, setTriggerPublishCommentEdit] = useState(false); + const [isImageSearchOpen, setIsImageSearchOpen] = useState(false); + const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false); + const [commentCid, setCommentCid] = useState(null); - const threadMenuRefs = useRef({}); - const threadRefs = useRef({}); - const postMenuRef = useRef(null); - const popupRef = useRef(null); - const imageRef = useRef(null); - const postMenuCatalogRef = useRef(null); - const textRef = useRef(null); - const { subplebbitAddress } = useParams(); + const threadMenuRefs = useRef({}); + const threadRefs = useRef({}); + const postMenuRef = useRef(null); + const popupRef = useRef(null); + const imageRef = useRef(null); + const postMenuCatalogRef = useRef(null); + const textRef = useRef(null); + const { subplebbitAddress } = useParams(); - const [, setNewErrorMessage] = useError(); - const [, setNewSuccessMessage] = useSuccess(); + const [, setNewErrorMessage] = useError(); + const [, setNewSuccessMessage] = useSuccess(); - const subplebbit = useSubplebbit({ subplebbitAddress: selectedAddress }); + const subplebbit = useSubplebbit({ subplebbitAddress: selectedAddress }); - const account = useAccount(); - const [spaceOnRight, setSpaceOnRight] = useState(null); - const [isCalculationDone, setIsCalculationDone] = useState(false); - const [hoverTimeoutId, setHoverTimeoutId] = useState(null); - const [isHoveringForMenu, setIsHoveringForMenu] = useState(false); - const textRect = textRef.current?.getBoundingClientRect(); - const imageRect = imageRef.current?.getBoundingClientRect(); - const popupRect = popupRef.current?.getBoundingClientRect(); - const isMediaShowed = - thread.link && - commentMediaInfo && - (commentMediaInfo.type === 'image' || - commentMediaInfo.type === 'video' || - (commentMediaInfo.type === 'webpage' && commentMediaInfo.thumbnail) || - (commentMediaInfo.type === 'iframe' && commentMediaInfo.thumbnail)) - ? true - : false; + const account = useAccount(); + const [spaceOnRight, setSpaceOnRight] = useState(null); + const [isCalculationDone, setIsCalculationDone] = useState(false); + const [hoverTimeoutId, setHoverTimeoutId] = useState(null); + const [isHoveringForMenu, setIsHoveringForMenu] = useState(false); + const textRect = textRef.current?.getBoundingClientRect(); + const imageRect = imageRef.current?.getBoundingClientRect(); + const popupRect = popupRef.current?.getBoundingClientRect(); + const isMediaShowed = + thread.link && + commentMediaInfo && + (commentMediaInfo.type === 'image' || + commentMediaInfo.type === 'video' || + (commentMediaInfo.type === 'webpage' && commentMediaInfo.thumbnail) || + (commentMediaInfo.type === 'iframe' && commentMediaInfo.thumbnail)) + ? true + : false; - const { left: textLeft, right: textRight, width: textWidth } = textRef.current?.getBoundingClientRect() || {}; - const { left: imageLeft, right: imageRight, width: imageWidth } = imageRef.current?.getBoundingClientRect() || {}; + const { left: textLeft, right: textRight, width: textWidth } = textRef.current?.getBoundingClientRect() || {}; + const { left: imageLeft, right: imageRight, width: imageWidth } = imageRef.current?.getBoundingClientRect() || {}; - useLayoutEffect(() => { - const executeLayoutEffectLogic = () => { - let ref; + useLayoutEffect(() => { + const executeLayoutEffectLogic = () => { + let ref; - if (isMediaShowed) { - ref = imageRef.current; - } else { - ref = textRef.current; - } + if (isMediaShowed) { + ref = imageRef.current; + } else { + ref = textRef.current; + } - if (ref && popupRef.current) { - const rect = ref.getBoundingClientRect(); - const viewportWidth = document.documentElement.clientWidth; - const spaceRight = viewportWidth - (rect.left + rect.width); - const spaceLeft = rect.left; + if (ref && popupRef.current) { + const rect = ref.getBoundingClientRect(); + const viewportWidth = document.documentElement.clientWidth; + const spaceRight = viewportWidth - (rect.left + rect.width); + const spaceLeft = rect.left; - if (spaceRight < 200 && spaceLeft > spaceRight && spaceLeft < 500) { - popupRef.current.style.maxWidth = `calc( + if (spaceRight < 200 && spaceLeft > spaceRight && spaceLeft < 500) { + popupRef.current.style.maxWidth = `calc( 100vw - ${isMediaShowed ? imageWidth : textWidth}px - ${spaceRight + 40}px )`; - } else if (spaceRight < 200 && spaceLeft < spaceRight) { - popupRef.current.style.maxWidth = `calc(100vw - ${isMediaShowed ? imageWidth : textWidth}px)`; - } else { - popupRef.current.style.maxWidth = `500px`; - } + } else if (spaceRight < 200 && spaceLeft < spaceRight) { + popupRef.current.style.maxWidth = `calc(100vw - ${isMediaShowed ? imageWidth : textWidth}px)`; + } else { + popupRef.current.style.maxWidth = `500px`; + } - setSpaceOnRight(spaceRight); - setIsCalculationDone(true); - } - }; + setSpaceOnRight(spaceRight); + setIsCalculationDone(true); + } + }; - if (isHoveringOnThread) { - const timeoutId = setTimeout(executeLayoutEffectLogic, 250); - return () => { - clearTimeout(timeoutId); - setIsCalculationDone(false); - }; - } - }, [isHoveringOnThread, isMediaShowed, textLeft, textRight, imageLeft, imageRight, textWidth, imageWidth]); + if (isHoveringOnThread) { + const timeoutId = setTimeout(executeLayoutEffectLogic, 250); + return () => { + clearTimeout(timeoutId); + setIsCalculationDone(false); + }; + } + }, [isHoveringOnThread, isMediaShowed, textLeft, textRight, imageLeft, imageRight, textWidth, imageWidth]); - const handleMouseOnLeaveThread = () => { - if (hoverTimeoutId) { - clearTimeout(hoverTimeoutId); - setHoverTimeoutId(null); - setIsHoveringOnThread(''); - } else if (isHoveringOnThread !== '') { - setIsHoveringOnThread(''); - setIsCalculationDone(false); - } - }; + const handleMouseOnLeaveThread = () => { + if (hoverTimeoutId) { + clearTimeout(hoverTimeoutId); + setHoverTimeoutId(null); + setIsHoveringOnThread(''); + } else if (isHoveringOnThread !== '') { + setIsHoveringOnThread(''); + setIsCalculationDone(false); + } + }; - const handleOutsideClick = useCallback( - (e) => { - if (openMenuCid !== null && !postMenuRef.current.contains(e.target) && !postMenuCatalogRef.current.contains(e.target)) { - setOpenMenuCid(null); - } - }, - [openMenuCid], - ); + const handleOutsideClick = useCallback( + (e) => { + if (openMenuCid !== null && !postMenuRef.current.contains(e.target) && !postMenuCatalogRef.current.contains(e.target)) { + setOpenMenuCid(null); + } + }, + [openMenuCid], + ); - const handleOptionClick = () => { - setOpenMenuCid(null); - }; + const handleOptionClick = () => { + setOpenMenuCid(null); + }; - useEffect(() => { - if (openMenuCid !== null) { - document.addEventListener('click', handleOutsideClick); - } else { - document.removeEventListener('click', handleOutsideClick); - } + useEffect(() => { + if (openMenuCid !== null) { + document.addEventListener('click', handleOutsideClick); + } else { + document.removeEventListener('click', handleOutsideClick); + } - return () => { - document.removeEventListener('click', handleOutsideClick); - }; - }, [openMenuCid, handleOutsideClick]); + return () => { + document.removeEventListener('click', handleOutsideClick); + }; + }, [openMenuCid, handleOutsideClick]); - const handleAuthorDeleteClick = (comment) => { - handleOptionClick(comment.cid); + const handleAuthorDeleteClick = (comment) => { + handleOptionClick(comment.cid); - confirmAlert({ - customUI: ({ onClose }) => { - return ( - -
-

Are you sure you want to delete this post?

-
- - -
-
-
- ); - }, - }); - }; + confirmAlert({ + customUI: ({ onClose }) => { + return ( + +
+

Are you sure you want to delete this post?

+
+ + +
+
+
+ ); + }, + }); + }; - const handleAuthorEditClick = (comment) => { - handleOptionClick(comment.cid); - setIsAuthorEdit(true); - setIsAuthorDelete(false); - setCommentCid(comment.cid); - setOriginalCommentContent(comment.content); - setIsEditModalOpen(true); - }; + const handleAuthorEditClick = (comment) => { + handleOptionClick(comment.cid); + setIsAuthorEdit(true); + setIsAuthorDelete(false); + setCommentCid(comment.cid); + setOriginalCommentContent(comment.content); + setIsEditModalOpen(true); + }; - const onChallengeVerification = (challengeVerification) => { - if (challengeVerification.challengeSuccess === true) { - setNewSuccessMessage('Challenge Success'); - console.log('challenge success', challengeVerification); - } else if (challengeVerification.challengeSuccess === false) { - setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); - console.log('challenge failed', challengeVerification); - } - }; + const onChallengeVerification = (challengeVerification) => { + if (challengeVerification.challengeSuccess === true) { + setNewSuccessMessage('Challenge Success'); + console.log('challenge success', challengeVerification); + } else if (challengeVerification.challengeSuccess === false) { + setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); + console.log('challenge failed', challengeVerification); + } + }; - const onChallenge = async (challenges, comment) => { - setPendingComment(comment); - let challengeAnswers = []; + const onChallenge = async (challenges, comment) => { + setPendingComment(comment); + let challengeAnswers = []; - try { - challengeAnswers = await getChallengeAnswersFromUser(challenges); - } catch (error) { - setNewErrorMessage(error.message); - console.log(error); - } - if (challengeAnswers) { - await comment.publishChallengeAnswers(challengeAnswers); - } - }; + try { + challengeAnswers = await getChallengeAnswersFromUser(challenges); + } catch (error) { + setNewErrorMessage(error.message); + console.log(error); + } + if (challengeAnswers) { + await comment.publishChallengeAnswers(challengeAnswers); + } + }; - const [publishCommentEditOptions, setPublishCommentEditOptions] = useState({ - commentCid: commentCid, - content: editedComment || undefined, - subplebbitAddress: selectedAddress || subplebbitAddress, - onChallenge, - onChallengeVerification, - onError: (error) => { - setNewErrorMessage(error.message); - console.log(error); - }, - }); + const [publishCommentEditOptions, setPublishCommentEditOptions] = useState({ + commentCid: commentCid, + content: editedComment || undefined, + subplebbitAddress: selectedAddress || subplebbitAddress, + onChallenge, + onChallengeVerification, + onError: (error) => { + setNewErrorMessage(error.message); + console.log(error); + }, + }); - const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions); + const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions); - useEffect(() => { - setPublishCommentEditOptions((prevOptions) => ({ - ...prevOptions, - commentCid: commentCid, - content: editedComment || undefined, - })); - }, [commentCid, editedComment]); + useEffect(() => { + setPublishCommentEditOptions((prevOptions) => ({ + ...prevOptions, + commentCid: commentCid, + content: editedComment || undefined, + })); + }, [commentCid, editedComment]); - useEffect(() => { - if (editedComment !== '') { - setTriggerPublishCommentEdit(true); - } - }, [editedComment]); + useEffect(() => { + if (editedComment !== '') { + setTriggerPublishCommentEdit(true); + } + }, [editedComment]); - useEffect(() => { - if (publishCommentEditOptions && triggerPublishCommentEdit) { - (async () => { - await publishCommentEdit(); - setTriggerPublishCommentEdit(false); - })(); - } - }, [publishCommentEditOptions, triggerPublishCommentEdit, publishCommentEdit]); + useEffect(() => { + if (publishCommentEditOptions && triggerPublishCommentEdit) { + (async () => { + await publishCommentEdit(); + setTriggerPublishCommentEdit(false); + })(); + } + }, [publishCommentEditOptions, triggerPublishCommentEdit, publishCommentEdit]); - const getChallengeAnswersFromUser = async (challenges) => { - setChallengesArray(challenges); + const getChallengeAnswersFromUser = async (challenges) => { + setChallengesArray(challenges); - return new Promise((resolve, reject) => { - const imageString = challenges?.challenges[0].challenge; - const imageSource = `data:image/png;base64,${imageString}`; - const challengeImg = new Image(); - challengeImg.src = imageSource; + return new Promise((resolve, reject) => { + const imageString = challenges?.challenges[0].challenge; + const imageSource = `data:image/png;base64,${imageString}`; + const challengeImg = new Image(); + challengeImg.src = imageSource; - challengeImg.onload = () => { - setIsCaptchaOpen(true); + challengeImg.onload = () => { + setIsCaptchaOpen(true); - const handleKeyDown = async (event) => { - if (event.key === 'Enter') { - const currentCaptchaResponse = captchaResponse; - resolve(currentCaptchaResponse); - setIsCaptchaOpen(false); - document.removeEventListener('keydown', handleKeyDown); - event.preventDefault(); - } - }; + const handleKeyDown = async (event) => { + if (event.key === 'Enter') { + const currentCaptchaResponse = captchaResponse; + resolve(currentCaptchaResponse); + setIsCaptchaOpen(false); + document.removeEventListener('keydown', handleKeyDown); + event.preventDefault(); + } + }; - setCaptchaResponse(''); - document.addEventListener('keydown', handleKeyDown); + setCaptchaResponse(''); + document.addEventListener('keydown', handleKeyDown); - setResolveCaptchaPromise(resolve); - }; + setResolveCaptchaPromise(resolve); + }; - challengeImg.onerror = () => { - reject(setNewErrorMessage('Could not load challenges')); - }; - }); - }; + challengeImg.onerror = () => { + reject(setNewErrorMessage('Could not load challenges')); + }; + }); + }; - let displayWidth, displayHeight; - if (thread.linkWidth && thread.linkHeight) { - let scale = Math.min(1, 150 / Math.max(thread.linkWidth, thread.linkHeight)); - displayWidth = `${thread.linkWidth * scale}px`; - displayHeight = `${thread.linkHeight * scale}px`; - } else if (thread.link) { - displayWidth = '150px'; - displayHeight = '150px'; - } else { - displayWidth = '0px'; - displayHeight = '0px'; - } + let displayWidth, displayHeight; + if (thread.linkWidth && thread.linkHeight) { + let scale = Math.min(1, 150 / Math.max(thread.linkWidth, thread.linkHeight)); + displayWidth = `${thread.linkWidth * scale}px`; + displayHeight = `${thread.linkHeight * scale}px`; + } else if (thread.link) { + displayWidth = '150px'; + displayHeight = '150px'; + } else { + displayWidth = '0px'; + displayHeight = '0px'; + } - if (post.type === 'rules') { - return ( - <> - {isHoveringOnThread === 'rules' - ? createPortal( - -
handleMouseOnLeaveThread()} - style={{ - visibility: isCalculationDone ? 'visible' : 'hidden', - left: - isCalculationDone && spaceOnRight > 250 - ? textRect.right + 5 - : isCalculationDone && spaceOnRight < 250 - ? textRect.left - popupRect.width - 5 - : 'auto', - top: popupPosition.top + 5, - }} - > - Rules  by  - ## Board Admins - {thread.timestamp ? getFormattedTime(thread.timestamp) : null} -
-
, - document.body, - ) - : null} -
{ - threadRefs.current['rules'] = el; - }} - onMouseLeave={() => { - handleMouseOnLeaveThread(); - }} - > - { - setIsHoveringForMenu('rules'); - handleMouseOnLeaveThread(); - }} - onMouseLeave={() => setIsHoveringForMenu(false)} - > -
- R: 0 / L: 0 -
- - -
- { - threadMenuRefs.current['rules'] = el; - postMenuRef.current = el; - }} - className='post-menu-button' - id='post-menu-button-catalog' - rotated={openMenuCid === 'rules'} - onClick={(event) => { - event.stopPropagation(); - const rect = threadMenuRefs.current['rules'].getBoundingClientRect(); - setMenuPosition({ top: rect.top + window.scrollY, left: rect.left }); - setOpenMenuCid((prevCid) => (prevCid === 'rules' ? null : 'rules')); - }} - > - ▶ - -
- {createPortal( - { - postMenuCatalogRef.current = el; - }} - onClick={(event) => event.stopPropagation()} - style={{ position: 'absolute', top: menuPosition.top + 7, left: menuPosition.left }} - > -
-
    - {/* {isModerator ? ( + if (post.type === 'rules') { + return ( + <> + {isHoveringOnThread === 'rules' + ? createPortal( + +
    handleMouseOnLeaveThread()} + style={{ + visibility: isCalculationDone ? 'visible' : 'hidden', + left: + isCalculationDone && spaceOnRight > 250 + ? textRect.right + 5 + : isCalculationDone && spaceOnRight < 250 + ? textRect.left - popupRect.width - 5 + : 'auto', + top: popupPosition.top + 5, + }} + > + Rules  by  + ## Board Mods + {thread.timestamp ? getFormattedTime(thread.timestamp) : null} +
    +
    , + document.body, + ) + : null} +
    { + threadRefs.current['rules'] = el; + }} + onMouseLeave={() => { + handleMouseOnLeaveThread(); + }} + > + { + setIsHoveringForMenu('rules'); + handleMouseOnLeaveThread(); + }} + onMouseLeave={() => setIsHoveringForMenu(false)} + > +
    + R: 0 / L: 0 +
    + + +
    + { + threadMenuRefs.current['rules'] = el; + postMenuRef.current = el; + }} + className='post-menu-button' + id='post-menu-button-catalog' + rotated={openMenuCid === 'rules'} + onClick={(event) => { + event.stopPropagation(); + const rect = threadMenuRefs.current['rules'].getBoundingClientRect(); + setMenuPosition({ top: rect.top + window.scrollY, left: rect.left }); + setOpenMenuCid((prevCid) => (prevCid === 'rules' ? null : 'rules')); + }} + > + ▶ + +
    + {createPortal( + { + postMenuCatalogRef.current = el; + }} + onClick={(event) => event.stopPropagation()} + style={{ position: 'absolute', top: menuPosition.top + 7, left: menuPosition.left }} + > +
    +
      + {/* {isModerator ? ( <> change rules ) : null} */} -
    • { - setIsClientRedirectMenuOpen(true); - }} - onMouseLeave={() => { - setIsClientRedirectMenuOpen(false); - }} - > - View on » -
        -
      • handleOptionClick('rules')}> - - Plebbit - -
      • - {/*
      • handleOptionClick("rules")}> +
      • { + setIsClientRedirectMenuOpen(true); + }} + onMouseLeave={() => { + setIsClientRedirectMenuOpen(false); + }} + > + View on » + -
      • -
      -
    -
    , - document.body, - )} -
    - -
    -
    - { - setIsHoveringOnThread('rules'); - setIsHoveringForMenu('rules'); - const rect = threadRefs.current['rules'].getBoundingClientRect(); - setPopupPosition({ top: rect.top + window.scrollY, left: rect.left }); - }} - onMouseLeave={() => setIsHoveringForMenu(false)} - > - Rules - {': ' + subplebbit.rules?.map((rule, index) => `${index + 1}. ${rule}`).join(' ')} - -
    -
    - -
    - - ); - } else if (post.type === 'description') { - return ( - <> - {isHoveringOnThread === 'description' - ? createPortal( - -
    handleMouseOnLeaveThread()} - style={{ - visibility: isCalculationDone ? 'visible' : 'hidden', - left: - isCalculationDone && spaceOnRight > 250 - ? subplebbit.suggestedAvatarUrl - ? imageRect.right + 5 - : textRect.right + 5 - : isCalculationDone && spaceOnRight < 250 - ? subplebbit.suggestedAvatarUrl - ? imageRect.left - popupRect.width - 5 - : textRect.left - popupRect.width - 5 - : 'auto', - top: popupPosition.top + 5, - }} - > - Welcome to {subplebbit.title || subplebbit.address} by  - ## Board Admins - {thread.timestamp ? getFormattedTime(thread.timestamp) : null} -
    -
    , - document.body, - ) - : null} -
    { - threadRefs.current['description'] = el; - }} - onMouseLeave={() => { - handleMouseOnLeaveThread(); - }} - > - - {subplebbit.suggested?.avatarUrl ? ( - { - setIsHoveringOnThread('description'); - setIsHoveringForMenu('description'); - const rect = threadRefs.current['description'].getBoundingClientRect(); - setPopupPosition({ top: rect.top + window.scrollY, left: rect.left }); - }} - onMouseLeave={() => setIsHoveringForMenu(false)} - src={subplebbit.suggested?.avatarUrl} - alt='board avatar' - /> - ) : null} - - {subplebbit.suggested?.avatarUrl ? ( -
    - - -
    - ) : null} - { - setIsHoveringForMenu('description'); - handleMouseOnLeaveThread(); - }} - onMouseLeave={() => setIsHoveringForMenu(false)} - > -
    - R: 0 / L: 0 - {subplebbit.suggested?.avatarUrl ? null : ( -
    - - -
    - )} - { - threadMenuRefs.current['description'] = el; - postMenuRef.current = el; - }} - className='post-menu-button' - id='post-menu-button-catalog' - rotated={openMenuCid === 'description'} - onClick={(event) => { - event.stopPropagation(); - const rect = threadMenuRefs.current['description'].getBoundingClientRect(); - setMenuPosition({ top: rect.top + window.scrollY, left: rect.left }); - setOpenMenuCid((prevCid) => (prevCid === 'description' ? null : 'description')); - }} - > - ▶ - -
    - {createPortal( - { - postMenuCatalogRef.current = el; - }} - onClick={(event) => event.stopPropagation()} - style={{ position: 'absolute', top: menuPosition.top + 7, left: menuPosition.left }} - > -
    -
      - {/* {isModerator ? ( +
    • handleOptionClick('rules')}> + + Plebones + +
    • +
    + +
+
+
, + document.body, + )} +
+ +
+
+ { + setIsHoveringOnThread('rules'); + setIsHoveringForMenu('rules'); + const rect = threadRefs.current['rules'].getBoundingClientRect(); + setPopupPosition({ top: rect.top + window.scrollY, left: rect.left }); + }} + onMouseLeave={() => setIsHoveringForMenu(false)} + > + Rules + {': ' + subplebbit.rules?.map((rule, index) => `${index + 1}. ${rule}`).join(' ')} + +
+
+ +
+ + ); + } else if (post.type === 'description') { + return ( + <> + {isHoveringOnThread === 'description' + ? createPortal( + +
handleMouseOnLeaveThread()} + style={{ + visibility: isCalculationDone ? 'visible' : 'hidden', + left: + isCalculationDone && spaceOnRight > 250 + ? subplebbit.suggestedAvatarUrl + ? imageRect.right + 5 + : textRect.right + 5 + : isCalculationDone && spaceOnRight < 250 + ? subplebbit.suggestedAvatarUrl + ? imageRect.left - popupRect.width - 5 + : textRect.left - popupRect.width - 5 + : 'auto', + top: popupPosition.top + 5, + }} + > + Welcome to {subplebbit.title || subplebbit.address} by  + ## Board Mods + {thread.timestamp ? getFormattedTime(thread.timestamp) : null} +
+
, + document.body, + ) + : null} +
{ + threadRefs.current['description'] = el; + }} + onMouseLeave={() => { + handleMouseOnLeaveThread(); + }} + > + + {subplebbit.suggested?.avatarUrl ? ( + { + setIsHoveringOnThread('description'); + setIsHoveringForMenu('description'); + const rect = threadRefs.current['description'].getBoundingClientRect(); + setPopupPosition({ top: rect.top + window.scrollY, left: rect.left }); + }} + onMouseLeave={() => setIsHoveringForMenu(false)} + src={subplebbit.suggested?.avatarUrl} + alt='board avatar' + /> + ) : null} + + {subplebbit.suggested?.avatarUrl ? ( +
+ + +
+ ) : null} + { + setIsHoveringForMenu('description'); + handleMouseOnLeaveThread(); + }} + onMouseLeave={() => setIsHoveringForMenu(false)} + > +
+ R: 0 / L: 0 + {subplebbit.suggested?.avatarUrl ? null : ( +
+ + +
+ )} + { + threadMenuRefs.current['description'] = el; + postMenuRef.current = el; + }} + className='post-menu-button' + id='post-menu-button-catalog' + rotated={openMenuCid === 'description'} + onClick={(event) => { + event.stopPropagation(); + const rect = threadMenuRefs.current['description'].getBoundingClientRect(); + setMenuPosition({ top: rect.top + window.scrollY, left: rect.left }); + setOpenMenuCid((prevCid) => (prevCid === 'description' ? null : 'description')); + }} + > + ▶ + +
+ {createPortal( + { + postMenuCatalogRef.current = el; + }} + onClick={(event) => event.stopPropagation()} + style={{ position: 'absolute', top: menuPosition.top + 7, left: menuPosition.left }} + > +
+
    + {/* {isModerator ? ( <> change description ) : null} */} - {subplebbit.suggested?.avatarUrl ? ( -
  • { - setIsImageSearchOpen(true); - }} - onMouseLeave={() => { - setIsImageSearchOpen(false); - }} - > - Image search » - -
  • - ) : null} -
  • { - setIsClientRedirectMenuOpen(true); - }} - onMouseLeave={() => { - setIsClientRedirectMenuOpen(false); - }} - > - View on » -
      -
    • handleOptionClick('description')}> - - Plebbit - -
    • - {/*
    • handleOptionClick("description")}> + {subplebbit.suggested?.avatarUrl ? ( +
    • { + setIsImageSearchOpen(true); + }} + onMouseLeave={() => { + setIsImageSearchOpen(false); + }} + > + Image search » + +
    • + ) : null} +
    • { + setIsClientRedirectMenuOpen(true); + }} + onMouseLeave={() => { + setIsClientRedirectMenuOpen(false); + }} + > + View on » + -
    • -
    -
-
, - document.body, - )} -
- setSelectedThread('description')}> -
-
- { - setIsHoveringOnThread('description'); - setIsHoveringForMenu('description'); - const rect = threadRefs.current['description'].getBoundingClientRect(); - setPopupPosition({ top: rect.top + window.scrollY, left: rect.left }); - }} - onMouseLeave={() => setIsHoveringForMenu(false)} - > - Welcome to {subplebbit.title || subplebbit.address}! - {': ' + subplebbit.description} - -
-
- -
- - ); - } else { - return ( - <> - {isHoveringOnThread === thread.cid - ? createPortal( - -
handleMouseOnLeaveThread()} - style={{ - visibility: isCalculationDone ? 'visible' : 'hidden', - left: - isCalculationDone && spaceOnRight > 250 - ? isMediaShowed - ? imageRect.right + 5 - : textRect.right + 5 - : isCalculationDone && spaceOnRight < 250 - ? isMediaShowed - ? imageRect.left - popupRect.width - 5 - : textRect.left - popupRect.width - 5 - : 'auto', - top: popupPosition.top + 5, - }} - > - {thread.title ? `${thread.title} ` : 'Posted '} - by - {thread.author.displayName ? ` ${thread.author.displayName} ` : ' Anonymous '} - {thread.timestamp ? getFormattedTime(thread.timestamp) : null} - {thread.replyCount > 0 ? ( -
- Last reply by - Anonymous - {getFormattedTime(thread.lastReplyTimestamp)} -
- ) : null} -
-
, - document.body, - ) - : null} -
{ - threadRefs.current[thread.cid] = el; - }} - onMouseLeave={() => { - handleMouseOnLeaveThread(); - }} - > - {commentMediaInfo?.url ? ( - setSelectedThread(thread.cid)} - onMouseOver={() => { - setIsHoveringOnThread(thread.cid); - setIsHoveringForMenu(thread.cid); - const rect = threadRefs.current[thread.cid].getBoundingClientRect(); - setPopupPosition({ top: rect.top + window.scrollY, left: rect.left }); - }} - onMouseLeave={() => setIsHoveringForMenu(false)} - > - {commentMediaInfo?.type === 'webpage' ? ( - thread.thumbnailUrl ? ( - - {commentMediaInfo.type} { - e.target.src = fallbackImgUrl; - e.target.onerror = null; - }} - /> - - ) : null - ) : null} - {commentMediaInfo?.type === 'iframe' && (thread.thumbnailUrl || commentMediaInfo.thumbnail) ? ( - - {commentMediaInfo.type} { - e.target.src = fallbackImgUrl; - }} - /> - - ) : null} - {commentMediaInfo?.type === 'image' ? ( - - {commentMediaInfo.type} { - e.target.src = fallbackImgUrl; - e.target.onerror = null; - }} - /> - - ) : null} - {commentMediaInfo?.type === 'video' ? ( - - - ) : null} - {commentMediaInfo?.type === 'audio' ? ( -
+ + ); + } else { + return ( + <> + {isHoveringOnThread === thread.cid + ? createPortal( + +
handleMouseOnLeaveThread()} + style={{ + visibility: isCalculationDone ? 'visible' : 'hidden', + left: + isCalculationDone && spaceOnRight > 250 + ? isMediaShowed + ? imageRect.right + 5 + : textRect.right + 5 + : isCalculationDone && spaceOnRight < 250 + ? isMediaShowed + ? imageRect.left - popupRect.width - 5 + : textRect.left - popupRect.width - 5 + : 'auto', + top: popupPosition.top + 5, + }} + > + {thread.title ? `${thread.title} ` : 'Posted '} + by + {thread.author.displayName ? ` ${thread.author.displayName} ` : ' Anonymous '} + {thread.timestamp ? getFormattedTime(thread.timestamp) : null} + {thread.replyCount > 0 ? ( +
+ Last reply by + Anonymous + {getFormattedTime(thread.lastReplyTimestamp)} +
+ ) : null} +
+
, + document.body, + ) + : null} +
{ + threadRefs.current[thread.cid] = el; + }} + onMouseLeave={() => { + handleMouseOnLeaveThread(); + }} + > + {commentMediaInfo?.url ? ( + setSelectedThread(thread.cid)} + onMouseOver={() => { + setIsHoveringOnThread(thread.cid); + setIsHoveringForMenu(thread.cid); + const rect = threadRefs.current[thread.cid].getBoundingClientRect(); + setPopupPosition({ top: rect.top + window.scrollY, left: rect.left }); + }} + onMouseLeave={() => setIsHoveringForMenu(false)} + > + {commentMediaInfo?.type === 'webpage' ? ( + thread.thumbnailUrl ? ( + + {commentMediaInfo.type} { + e.target.src = fallbackImgUrl; + e.target.onerror = null; + }} + /> + + ) : null + ) : null} + {commentMediaInfo?.type === 'iframe' && (thread.thumbnailUrl || commentMediaInfo.thumbnail) ? ( + + {commentMediaInfo.type} { + e.target.src = fallbackImgUrl; + }} + /> + + ) : null} + {commentMediaInfo?.type === 'image' ? ( + + {commentMediaInfo.type} { + e.target.src = fallbackImgUrl; + e.target.onerror = null; + }} + /> + + ) : null} + {commentMediaInfo?.type === 'video' ? ( + + + ) : null} + {commentMediaInfo?.type === 'audio' ? ( +
- - ); - } +
  • handleOptionClick(thread.cid)}> + + Plebones + +
  • + + + +
    + , + document.body, + )} + + setSelectedThread(thread.cid)}> +
    +
    + { + setIsHoveringOnThread(thread.cid); + setIsHoveringForMenu(thread.cid); + const rect = threadRefs.current[thread.cid].getBoundingClientRect(); + setPopupPosition({ top: rect.top + window.scrollY, left: rect.left }); + }} + onMouseLeave={() => setIsHoveringForMenu(false)} + > + {thread.title ? `${thread.title}` : null} + {thread.content ? `: ${thread.content}` : null} + +
    +
    + +
    + + ); + } }; const CatalogRow = ({ row }) => { - const posts = []; - for (const post of row) { - posts.push(); - } - return
    {posts}
    ; + const posts = []; + for (const post of row) { + posts.push(); + } + return
    {posts}
    ; }; const Catalog = () => { - const { - captchaResponse, - setCaptchaResponse, - setChallengesArray, - defaultSubplebbits, - setIsCaptchaOpen, - isModerationOpen, - setIsModerationOpen, - setIsModerator, - isSettingsOpen, - setIsSettingsOpen, - originalCommentContent, - setPendingComment, - setPendingCommentIndex, - setResolveCaptchaPromise, - selectedAddress, - setSelectedAddress, - selectedStyle, - selectedTitle, - setSelectedTitle, - showPostForm, - showPostFormLink, - } = useGeneralStore((state) => state); + const { + captchaResponse, + setCaptchaResponse, + setChallengesArray, + defaultSubplebbits, + setIsCaptchaOpen, + isModerationOpen, + setIsModerationOpen, + setIsModerator, + isSettingsOpen, + setIsSettingsOpen, + originalCommentContent, + setPendingComment, + setPendingCommentIndex, + setResolveCaptchaPromise, + selectedAddress, + setSelectedAddress, + selectedStyle, + selectedTitle, + setSelectedTitle, + showPostForm, + showPostFormLink, + } = useGeneralStore((state) => state); - const { anonymousMode } = useAnonModeStore(); + const { anonymousMode } = useAnonModeStore(); - const nameRef = useRef(); - const subjectRef = useRef(); - const commentRef = useRef(); - const linkRef = useRef(); - const selectedThreadCidRef = useRef(null); - const virtuosoRef = useRef(); + const nameRef = useRef(); + const subjectRef = useRef(); + const commentRef = useRef(); + const linkRef = useRef(); + const selectedThreadCidRef = useRef(null); + const virtuosoRef = useRef(); - const navigate = useNavigate(); + const navigate = useNavigate(); - const [, setNewErrorMessage] = useError(); - const [, setNewSuccessMessage] = useSuccess(); + const [, setNewErrorMessage] = useError(); + const [, setNewSuccessMessage] = useSuccess(); - const [triggerPublishComment, setTriggerPublishComment] = useState(false); - const [prevScrollPos, setPrevScrollPos] = useState(0); - const [visible, setVisible] = useState(true); - const [isEditModalOpen, setIsEditModalOpen] = useState(false); - const [deletePost, setDeletePost] = useState(false); - const [executeAnonMode, setExecuteAnonMode] = useState(false); - const [isCreateBoardOpen, setIsCreateBoardOpen] = useState(false); + const [triggerPublishComment, setTriggerPublishComment] = useState(false); + const [prevScrollPos, setPrevScrollPos] = useState(0); + const [visible, setVisible] = useState(true); + const [isEditModalOpen, setIsEditModalOpen] = useState(false); + const [deletePost, setDeletePost] = useState(false); + const [executeAnonMode, setExecuteAnonMode] = useState(false); + const [isCreateBoardOpen, setIsCreateBoardOpen] = useState(false); - useAnonModeRef(selectedThreadCidRef, anonymousMode && executeAnonMode); + useAnonModeRef(selectedThreadCidRef, anonymousMode && executeAnonMode); - const account = useAccount(); - const { feed, hasMore, loadMore } = useFeed({ subplebbitAddresses: [`${selectedAddress}`], sortType: 'active' }); - const { subplebbitAddress } = useParams(); - const subplebbit = useSubplebbit({ subplebbitAddress: selectedAddress }); - const stateString = useStateString(subplebbit); - let feedWithDescriptionAndRules = [...feed]; + const account = useAccount(); + const { feed, hasMore, loadMore } = useFeed({ subplebbitAddresses: [`${selectedAddress}`], sortType: 'active' }); + const { subplebbitAddress } = useParams(); + const subplebbit = useSubplebbit({ subplebbitAddress: selectedAddress }); + const stateString = useStateString(subplebbit); + let feedWithDescriptionAndRules = [...feed]; - if (subplebbit.rules) { - feedWithDescriptionAndRules.unshift({ type: 'rules', content: subplebbit.rules }); - } + if (subplebbit.rules) { + feedWithDescriptionAndRules.unshift({ type: 'rules', content: subplebbit.rules }); + } - if (subplebbit.description) { - feedWithDescriptionAndRules.unshift({ type: 'description', content: subplebbit.description }); - } + if (subplebbit.description) { + feedWithDescriptionAndRules.unshift({ type: 'description', content: subplebbit.description }); + } - const columnWidth = 180; - const windowWidth = useWindowWidth(); - const columnCount = Math.floor(windowWidth / columnWidth); - const rows = useFeedRows(feedWithDescriptionAndRules, columnCount); + const columnWidth = 180; + const windowWidth = useWindowWidth(); + const columnCount = Math.floor(windowWidth / columnWidth); + const rows = useFeedRows(feedWithDescriptionAndRules, columnCount); - useEffect(() => { - if (subplebbit.roles !== undefined) { - const role = subplebbit.roles[account?.author.address]?.role; + useEffect(() => { + if (subplebbit.roles !== undefined) { + const role = subplebbit.roles[account?.author.address]?.role; - if (role === 'moderator' || role === 'admin' || role === 'owner') { - setIsModerator(true); - } else { - setIsModerator(false); - } - } - }, [account?.author.address, subplebbit.roles, setIsModerator]); + if (role === 'moderator' || role === 'admin' || role === 'owner') { + setIsModerator(true); + } else { + setIsModerator(false); + } + } + }, [account?.author.address, subplebbit.roles, setIsModerator]); - useEffect(() => { - setSelectedAddress(subplebbitAddress); - }, [subplebbitAddress, setSelectedAddress]); + useEffect(() => { + setSelectedAddress(subplebbitAddress); + }, [subplebbitAddress, setSelectedAddress]); - const errorString = useMemo(() => { - if (subplebbit?.state === 'failed') { - let errorString = 'Failed fetching board "' + selectedAddress + '".'; - if (subplebbit.error) { - errorString += `: ${subplebbit.error.toString().slice(0, 300)}`; - } - return errorString; - } - }, [subplebbit?.state, subplebbit?.error, selectedAddress]); + const errorString = useMemo(() => { + if (subplebbit?.state === 'failed') { + let errorString = 'Failed fetching board "' + selectedAddress + '".'; + if (subplebbit.error) { + errorString += `: ${subplebbit.error.toString().slice(0, 300)}`; + } + return errorString; + } + }, [subplebbit?.state, subplebbit?.error, selectedAddress]); - useEffect(() => { - if (errorString) { - setNewErrorMessage(errorString); - } - }, [errorString, setNewErrorMessage]); + useEffect(() => { + if (errorString) { + setNewErrorMessage(errorString); + } + }, [errorString, setNewErrorMessage]); - const { subscribed, subscribe, unsubscribe } = useSubscribe({ subplebbitAddress: selectedAddress }); + const { subscribed, subscribe, unsubscribe } = useSubscribe({ subplebbitAddress: selectedAddress }); - useEffect(() => { - const selectedSubplebbit = defaultSubplebbits.find((subplebbit) => subplebbit.address === subplebbitAddress); - if (subplebbitAddress) { - setSelectedAddress(subplebbitAddress); - } else if (subplebbit?.address) { - setSelectedAddress(subplebbit.address); - } - if (selectedSubplebbit) { - setSelectedTitle(selectedSubplebbit.title); - } else if (subplebbit?.title) { - setSelectedTitle(subplebbit.title); - } - }, [subplebbitAddress, setSelectedAddress, setSelectedTitle, defaultSubplebbits, subplebbit?.address, subplebbit?.title]); + useEffect(() => { + const selectedSubplebbit = defaultSubplebbits.find((subplebbit) => subplebbit.address === subplebbitAddress); + if (subplebbitAddress) { + setSelectedAddress(subplebbitAddress); + } else if (subplebbit?.address) { + setSelectedAddress(subplebbit.address); + } + if (selectedSubplebbit) { + setSelectedTitle(selectedSubplebbit.title); + } else if (subplebbit?.title) { + setSelectedTitle(subplebbit.title); + } + }, [subplebbitAddress, setSelectedAddress, setSelectedTitle, defaultSubplebbits, subplebbit?.address, subplebbit?.title]); - // mobile navbar scroll effect - useEffect(() => { - const debouncedHandleScroll = debounce(() => { - const currentScrollPos = window.pageYOffset; - setVisible(prevScrollPos > currentScrollPos || currentScrollPos < 10); - setPrevScrollPos(currentScrollPos); - }, 50); + // mobile navbar scroll effect + useEffect(() => { + const debouncedHandleScroll = debounce(() => { + const currentScrollPos = window.pageYOffset; + setVisible(prevScrollPos > currentScrollPos || currentScrollPos < 10); + setPrevScrollPos(currentScrollPos); + }, 50); - window.addEventListener('scroll', debouncedHandleScroll); + window.addEventListener('scroll', debouncedHandleScroll); - return () => window.removeEventListener('scroll', debouncedHandleScroll); - }, [prevScrollPos, visible]); + return () => window.removeEventListener('scroll', debouncedHandleScroll); + }, [prevScrollPos, visible]); - const onChallengeVerification = (challengeVerification) => { - if (challengeVerification.challengeSuccess === true) { - if (challengeVerification.publication?.cid !== undefined) { - navigate(`/p/${subplebbitAddress}/c/${challengeVerification.publication?.cid}`); - console.log('challenge success'); - } else { - setNewSuccessMessage('Challenge Success'); - console.log('challenge success', challengeVerification); - } - } else if (challengeVerification.challengeSuccess === false) { - setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); - console.log('challenge failed', challengeVerification); - } - }; + const onChallengeVerification = (challengeVerification) => { + if (challengeVerification.challengeSuccess === true) { + if (challengeVerification.publication?.cid !== undefined) { + navigate(`/p/${subplebbitAddress}/c/${challengeVerification.publication?.cid}`); + console.log('challenge success'); + } else { + setNewSuccessMessage('Challenge Success'); + console.log('challenge success', challengeVerification); + } + } else if (challengeVerification.challengeSuccess === false) { + setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`); + console.log('challenge failed', challengeVerification); + } + }; - const onChallenge = async (challenges, comment) => { - setPendingComment(comment); - let challengeAnswers = []; + const onChallenge = async (challenges, comment) => { + setPendingComment(comment); + let challengeAnswers = []; - try { - challengeAnswers = await getChallengeAnswersFromUser(challenges); - } catch (error) { - setNewErrorMessage(error.message); - console.log(error); - } - if (challengeAnswers) { - await comment.publishChallengeAnswers(challengeAnswers); - } - }; + try { + challengeAnswers = await getChallengeAnswersFromUser(challenges); + } catch (error) { + setNewErrorMessage(error.message); + console.log(error); + } + if (challengeAnswers) { + await comment.publishChallengeAnswers(challengeAnswers); + } + }; - useEffect(() => { - setPublishCommentOptions((prevPublishCommentOptions) => ({ - ...prevPublishCommentOptions, - subplebbitAddress: selectedAddress, - })); - }, [selectedAddress]); + useEffect(() => { + setPublishCommentOptions((prevPublishCommentOptions) => ({ + ...prevPublishCommentOptions, + subplebbitAddress: selectedAddress, + })); + }, [selectedAddress]); - const [publishCommentOptions, setPublishCommentOptions] = useState({ - subplebbitAddress: selectedAddress, - onChallenge, - onChallengeVerification, - onError: (error) => { - setNewErrorMessage(error.message); - console.log(error); - }, - }); + const [publishCommentOptions, setPublishCommentOptions] = useState({ + subplebbitAddress: selectedAddress, + onChallenge, + onChallengeVerification, + onError: (error) => { + setNewErrorMessage(error.message); + console.log(error); + }, + }); - const { publishComment, index } = usePublishComment(publishCommentOptions); + const { publishComment, index } = usePublishComment(publishCommentOptions); - useEffect(() => { - if (index !== undefined) { - setPendingCommentIndex(index); - navigate(`/profile/c/${index}`); - } - }, [index, navigate, setPendingCommentIndex]); + useEffect(() => { + if (index !== undefined) { + setPendingCommentIndex(index); + navigate(`/profile/c/${index}`); + } + }, [index, navigate, setPendingCommentIndex]); - const resetFields = useCallback(() => { - if (nameRef.current) { - nameRef.current.value = ''; - } - if (subjectRef.current) { - subjectRef.current.value = ''; - } - if (commentRef.current) { - commentRef.current.value = ''; - } - if (linkRef.current) { - linkRef.current.value = ''; - } - }, []); + const resetFields = useCallback(() => { + if (nameRef.current) { + nameRef.current.value = ''; + } + if (subjectRef.current) { + subjectRef.current.value = ''; + } + if (commentRef.current) { + commentRef.current.value = ''; + } + if (linkRef.current) { + linkRef.current.value = ''; + } + }, []); - const handleSubmit = async (event) => { - event.preventDefault(); + const handleSubmit = async (event) => { + event.preventDefault(); - if (subjectRef.current.value === '') { - setNewErrorMessage('Subject field is mandatory'); - return; - } + if (subjectRef.current.value === '') { + setNewErrorMessage('Subject field is mandatory'); + return; + } - setPublishCommentOptions((prevPublishCommentOptions) => ({ - ...prevPublishCommentOptions, - author: { - displayName: nameRef.current.value || undefined, - ...(anonymousMode ? {} : { address: account?.author.address }), - }, - title: subjectRef.current.value || undefined, - content: commentRef.current.value || undefined, - link: linkRef.current.value || undefined, - })); + setPublishCommentOptions((prevPublishCommentOptions) => ({ + ...prevPublishCommentOptions, + author: { + displayName: nameRef.current.value || undefined, + ...(anonymousMode ? {} : { address: account?.author.address }), + }, + title: subjectRef.current.value || undefined, + content: commentRef.current.value || undefined, + link: linkRef.current.value || undefined, + })); - setTriggerPublishComment(true); - }; + setTriggerPublishComment(true); + }; - const updateSigner = useCallback(async () => { - if (anonymousMode) { - setExecuteAnonMode(true); + const updateSigner = useCallback(async () => { + if (anonymousMode) { + setExecuteAnonMode(true); - let storedSigners = JSON.parse(localStorage.getItem('storedSigners')) || {}; - let signer; + let storedSigners = JSON.parse(localStorage.getItem('storedSigners')) || {}; + let signer; - if (!storedSigners[selectedThreadCidRef]) { - signer = await account?.plebbit.createSigner(); - storedSigners[selectedThreadCidRef] = { privateKey: signer?.privateKey, address: signer?.address }; - localStorage.setItem('storedSigners', JSON.stringify(storedSigners)); - } else { - const signerPrivateKey = storedSigners[selectedThreadCidRef].privateKey; + if (!storedSigners[selectedThreadCidRef]) { + signer = await account?.plebbit.createSigner(); + storedSigners[selectedThreadCidRef] = { privateKey: signer?.privateKey, address: signer?.address }; + localStorage.setItem('storedSigners', JSON.stringify(storedSigners)); + } else { + const signerPrivateKey = storedSigners[selectedThreadCidRef].privateKey; - try { - signer = await account?.plebbit.createSigner({ type: 'ed25519', privateKey: signerPrivateKey }); - } catch (error) { - console.log(error); - } - } + try { + signer = await account?.plebbit.createSigner({ type: 'ed25519', privateKey: signerPrivateKey }); + } catch (error) { + console.log(error); + } + } - setPublishCommentOptions((prevPublishCommentOptions) => { - const newPublishCommentOptions = { - ...prevPublishCommentOptions, - signer, - author: { - ...prevPublishCommentOptions.author, - address: signer?.address, - }, - }; + setPublishCommentOptions((prevPublishCommentOptions) => { + const newPublishCommentOptions = { + ...prevPublishCommentOptions, + signer, + author: { + ...prevPublishCommentOptions.author, + address: signer?.address, + }, + }; - if (JSON.stringify(prevPublishCommentOptions) !== JSON.stringify(newPublishCommentOptions)) { - return newPublishCommentOptions; - } + if (JSON.stringify(prevPublishCommentOptions) !== JSON.stringify(newPublishCommentOptions)) { + return newPublishCommentOptions; + } - return prevPublishCommentOptions; - }); - } - }, [selectedThreadCidRef, anonymousMode, account]); + return prevPublishCommentOptions; + }); + } + }, [selectedThreadCidRef, anonymousMode, account]); - useEffect(() => { - updateSigner(); - }, [updateSigner]); + useEffect(() => { + updateSigner(); + }, [updateSigner]); - useEffect(() => { - if (publishCommentOptions && triggerPublishComment) { - (async () => { - await publishComment(); - resetFields(); - })(); - setTriggerPublishComment(false); - setExecuteAnonMode(false); - } - }, [publishCommentOptions, triggerPublishComment, publishComment, resetFields]); + useEffect(() => { + if (publishCommentOptions && triggerPublishComment) { + (async () => { + await publishComment(); + resetFields(); + })(); + setTriggerPublishComment(false); + setExecuteAnonMode(false); + } + }, [publishCommentOptions, triggerPublishComment, publishComment, resetFields]); - const getChallengeAnswersFromUser = async (challenges) => { - setChallengesArray(challenges); + const getChallengeAnswersFromUser = async (challenges) => { + setChallengesArray(challenges); - return new Promise((resolve, reject) => { - const imageString = challenges?.challenges[0].challenge; - const imageSource = `data:image/png;base64,${imageString}`; - const challengeImg = new Image(); - challengeImg.src = imageSource; + return new Promise((resolve, reject) => { + const imageString = challenges?.challenges[0].challenge; + const imageSource = `data:image/png;base64,${imageString}`; + const challengeImg = new Image(); + challengeImg.src = imageSource; - challengeImg.onload = () => { - setIsCaptchaOpen(true); + challengeImg.onload = () => { + setIsCaptchaOpen(true); - const handleKeyDown = async (event) => { - if (event.key === 'Enter') { - const currentCaptchaResponse = captchaResponse; - resolve(currentCaptchaResponse); - setIsCaptchaOpen(false); - document.removeEventListener('keydown', handleKeyDown); - event.preventDefault(); - } - }; + const handleKeyDown = async (event) => { + if (event.key === 'Enter') { + const currentCaptchaResponse = captchaResponse; + resolve(currentCaptchaResponse); + setIsCaptchaOpen(false); + document.removeEventListener('keydown', handleKeyDown); + event.preventDefault(); + } + }; - setCaptchaResponse(''); - document.addEventListener('keydown', handleKeyDown); + setCaptchaResponse(''); + document.addEventListener('keydown', handleKeyDown); - setResolveCaptchaPromise(resolve); - }; + setResolveCaptchaPromise(resolve); + }; - challengeImg.onerror = () => { - reject(setNewErrorMessage('Could not load challenges')); - }; - }); - }; + challengeImg.onerror = () => { + reject(setNewErrorMessage('Could not load challenges')); + }; + }); + }; - // mobile navbar board select functionality - const handleSelectChange = (event) => { - const selected = event.target.value; + // mobile navbar board select functionality + const handleSelectChange = (event) => { + const selected = event.target.value; - if (selected === 'subscriptions') { - navigate(`/p/subscriptions`); - return; - } else if (selected === 'all') { - navigate(`/p/all`); - return; - } + if (selected === 'subscriptions') { + navigate(`/p/subscriptions`); + return; + } else if (selected === 'all') { + navigate(`/p/all`); + return; + } - const selectedTitle = defaultSubplebbits.find((subplebbit) => subplebbit.address === selected).title; - setSelectedTitle(selectedTitle); - setSelectedAddress(selected); - navigate(`/p/${selected}`); - }; + const selectedTitle = defaultSubplebbits.find((subplebbit) => subplebbit.address === selected).title; + setSelectedTitle(selectedTitle); + setSelectedAddress(selected); + navigate(`/p/${selected}`); + }; - const handleSubscribe = async () => { - try { - if (subscribed === false) { - await subscribe(selectedAddress); - } else if (subscribed === true) { - await unsubscribe(selectedAddress); - } - } catch (error) { - setNewErrorMessage(error.message); - console.log(error); - } - }; + const handleSubscribe = async () => { + try { + if (subscribed === false) { + await subscribe(selectedAddress); + } else if (subscribed === true) { + await unsubscribe(selectedAddress); + } + } catch (error) { + setNewErrorMessage(error.message); + console.log(error); + } + }; - useEffect(() => { - const setLastVirtuosoState = () => { - virtuosoRef.current?.getState((snapshot) => { - if (snapshot?.scrollTop === 0 || snapshot?.ranges?.length) { - lastVirtuosoStates[`${selectedAddress}-catalog`] = snapshot; - } - }); - }; - window.addEventListener('scroll', setLastVirtuosoState); + useEffect(() => { + const setLastVirtuosoState = () => { + virtuosoRef.current?.getState((snapshot) => { + if (snapshot?.scrollTop === 0 || snapshot?.ranges?.length) { + lastVirtuosoStates[`${selectedAddress}-catalog`] = snapshot; + } + }); + }; + window.addEventListener('scroll', setLastVirtuosoState); - return () => window.removeEventListener('scroll', setLastVirtuosoState); - }, [selectedAddress]); + return () => window.removeEventListener('scroll', setLastVirtuosoState); + }, [selectedAddress]); - const lastVirtuosoState = lastVirtuosoStates[`${selectedAddress}-catalog`]; + const lastVirtuosoState = lastVirtuosoStates[`${selectedAddress}-catalog`]; - return ( - <> - - {(selectedTitle ? selectedTitle : selectedAddress) + ' - Catalog - plebchan'} - - - setIsCreateBoardOpen(false)} /> - setIsSettingsOpen(false)} /> - { - setIsModerationOpen(false); - setDeletePost(false); - }} - deletePost={deletePost} - /> - setIsEditModalOpen(false)} originalCommentContent={originalCommentContent} /> - - <> - - [ - window.scrollTo(0, 0)}> - All - -  /  - window.scrollTo(0, 0)}> - Subscriptions - - ] [ - {defaultSubplebbits.map((subplebbit, index) => ( - - {index === 0 ? null : '\u00a0'} - { - setSelectedTitle(subplebbit.title); - setSelectedAddress(subplebbit.address); - }} - > - {subplebbit.title ? subplebbit.title : subplebbit.address} - - {index !== defaultSubplebbits.length - 1 ? ' /' : null} - - ))} - ] - - - [ - { - window.electron && window.electron.isElectron - ? setIsCreateBoardOpen(true) - : alert( - 'You can create a board with the desktop version of plebchan:\nhttps://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, use plebbit-cli:\nhttps://github.com/plebbit/plebbit-cli\n\n', - ); - }} - > - Create Board - - ] [ - setIsSettingsOpen(true)}> - Settings - - ] [Home] - -
    -
    -
    - Board -   - -   - - alert( - 'You can create a board with the desktop version of plebchan:\nhttps://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, use plebbit-cli:\nhttps://github.com/plebbit/plebbit-cli\n\n', - ) - } - > - Create Board - -
    -
    - setIsSettingsOpen(true)}> - Settings - -   - { - handleStyleChange({ target: { value: 'Yotsuba' } }); - window.scrollTo(0, 0); - }} - > - Home - -
    -
    -
    -
     
    -
     
    - -
    -
    - <> -
    - -
    - <> -
    {subplebbit.title ?? null}
    -
    - p/{subplebbit.address} - -
    - - -
    - - - -
    - [ - (event.target.style.cursor = 'pointer')}> - Start a New Thread - - ] -
    -
    - - (event.target.style.cursor = 'pointer')}> - Start a New Thread - - -
    -
    - - - - Name - - {account?.author.displayName ? ( - - ) : ( - - )} - - - - Subject - - - - - - - Comment - -