From 869d653ce30a93a5cf572921e6e8f9c60d65322a Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 17 Jun 2023 20:24:38 +0200 Subject: [PATCH] update anon mode --- src/components/modals/SettingsModal.jsx | 67 +++++------------- .../styled/modals/SettingsModal.styled.jsx | 29 +++++++- src/components/views/All.jsx | 32 ++++----- src/components/views/AllCatalog.jsx | 20 ++---- src/components/views/Board.jsx | 69 +++++++------------ src/components/views/Catalog.jsx | 61 +++++----------- src/components/views/Home.jsx | 5 +- src/components/views/Subscriptions.jsx | 12 ++-- src/components/views/Thread.jsx | 18 ++--- 9 files changed, 118 insertions(+), 195 deletions(-) diff --git a/src/components/modals/SettingsModal.jsx b/src/components/modals/SettingsModal.jsx index f1590627..62bca6f0 100755 --- a/src/components/modals/SettingsModal.jsx +++ b/src/components/modals/SettingsModal.jsx @@ -1,10 +1,8 @@ import React, { useState, useEffect, useRef } from "react"; import { Link, useLocation, useNavigate } from "react-router-dom"; -import { confirmAlert } from "react-confirm-alert"; import Modal from "react-modal"; import { deleteCaches, exportAccount, importAccount, setAccount, setActiveAccount, useAccount, useAccounts } from "@plebbit/plebbit-react-hooks"; import { StyledModal } from "../styled/modals/SettingsModal.styled"; -import { AuthorDeleteAlert } from '../styled/views/Thread.styled'; import useError from "../../hooks/useError"; import useSuccess from "../../hooks/useSuccess"; import useAnonModeStore from '../../hooks/stores/useAnonModeStore'; @@ -196,38 +194,6 @@ const SettingsModal = ({ isOpen, closeModal }) => { } }; - - const handleAnonymousMode = () => { - confirmAlert({ - customUI: ({ onClose }) => { - return ( - -
-

- { !anonymousMode ? - "Enabling anonymous mode will turn off all account-based features, such as subscribing to boards." : - "Disabling anonymous mode will turn on all account-based features, such as subscribing to boards." - } -

-
- - -
-
-
- ) - } - }) - }; - - return ( { ] - -
{feed.length > 0 ? ( <> - {anonymousMode ? null : ( - <> - - [ - - handleSubscribe()}> - {subscribed ? "Unsubscribe" : "Subscribe"} - - - ] - - - handleSubscribe()}> + + [ + + handleSubscribe()}> {subscribed ? "Unsubscribe" : "Subscribe"} - - - )} + + ] + + + handleSubscribe()}> + {subscribed ? "Unsubscribe" : "Subscribe"} + + ) : (
@@ -1064,12 +1043,8 @@ const Catalog = () => { [ All - {anonymousMode ? null : - <> -  /  - Subscriptions - - } +  /  + Subscriptions ]  {defaultSubplebbits.map((subplebbit, index) => ( diff --git a/src/components/views/Home.jsx b/src/components/views/Home.jsx index dd301cc5..ebd24ad3 100644 --- a/src/components/views/Home.jsx +++ b/src/components/views/Home.jsx @@ -5,7 +5,6 @@ import { Link, useNavigate } from 'react-router-dom'; import { Container, Header, Logo, Page, Search, About, AboutTitle, AboutContent, Boards, BoardsTitle, BoardsContent, Footer } from '../styled/views/Home.styled'; import BoardAvatar from '../BoardAvatar'; import OfflineIndicator from '../OfflineIndicator'; -import useAnonModeStore from '../../hooks/stores/useAnonModeStore'; import useGeneralStore from '../../hooks/stores/useGeneralStore'; import packageJson from '../../../package.json' import { Tooltip } from 'react-tooltip'; @@ -22,8 +21,6 @@ const Home = () => { selectedStyle, setSelectedStyle, setSelectedTitle } = useGeneralStore(state => state); - - const { anonymousMode } = useAnonModeStore(); const account = useAccount(); const navigate = useNavigate(); @@ -105,7 +102,7 @@ const Home = () => {
- {account?.subscriptions?.length > 0 && !anonymousMode ? ( + {account?.subscriptions?.length > 0 ? (

Subscriptions

diff --git a/src/components/views/Subscriptions.jsx b/src/components/views/Subscriptions.jsx index 67d8d88a..7c4a2139 100755 --- a/src/components/views/Subscriptions.jsx +++ b/src/components/views/Subscriptions.jsx @@ -678,7 +678,8 @@ const Subscriptions = () => { onClick={(e) => { if (e.button === 2) return; e.preventDefault(); - setIsReplyOpen(true); + setIsReplyOpen(true); + setSelectedThread(thread.cid); setSelectedShortCid(thread.shortCid); setSelectedParentCid(thread.cid); setSelectedAddress(thread.subplebbitAddress); @@ -957,7 +958,8 @@ const Subscriptions = () => { onClick={(e) => { if (e.button === 2) return; e.preventDefault(); - setIsReplyOpen(true); + setIsReplyOpen(true); + setSelectedThread(thread.cid); setSelectedShortCid(reply.shortCid); setSelectedParentCid(reply.cid); setSelectedAddress(thread.subplebbitAddress); @@ -1390,7 +1392,8 @@ const Subscriptions = () => { onClick={(e) => { if (e.button === 2) return; e.preventDefault(); - setIsReplyOpen(true); + setIsReplyOpen(true); + setSelectedThread(thread.cid); setSelectedShortCid(thread.shortCid); setSelectedParentCid(thread.cid); setSelectedAddress(thread.subplebbitAddress); @@ -1562,7 +1565,8 @@ const Subscriptions = () => { onClick={(e) => { if (e.button === 2) return; e.preventDefault(); - setIsReplyOpen(true); + setIsReplyOpen(true); + setSelectedThread(thread.cid); setSelectedShortCid(reply.shortCid); setSelectedParentCid(reply.cid); setSelectedAddress(thread.subplebbitAddress); diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index fd6a873a..65e20740 100755 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -532,12 +532,8 @@ const Thread = () => { [ All - {anonymousMode ? null : - <> -  /  - Subscriptions - - } +  /  + Subscriptions ] [ {defaultSubplebbits.map((subplebbit, index) => ( @@ -574,7 +570,7 @@ const Thread = () => {