diff --git a/package.json b/package.json
index 2aaf5ebe..1645bfee 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"dependencies": {
"@capacitor/app": "1.1.1",
"@floating-ui/react": "0.26.1",
- "@plebbit/plebbit-react-hooks": "https://github.com/plebbit/plebbit-react-hooks.git#f0ae8cd285f282d82eafd290e3b73525faa8ec6b",
+ "@plebbit/plebbit-react-hooks": "https://github.com/plebbit/plebbit-react-hooks.git#a80ef4b155abf119e66c019576cbc1b338390e00",
"@testing-library/jest-dom": "5.14.1",
"@testing-library/react": "13.0.0",
"@testing-library/user-event": "13.2.1",
diff --git a/src/app.tsx b/src/app.tsx
index ee561a73..8b1ea752 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -1,8 +1,6 @@
-import { useEffect } from 'react';
import { Outlet, Route, Routes, useLocation, useParams } from 'react-router-dom';
-import { isAllView, isHomeView, isSubscriptionsView } from './lib/utils/view-utils';
+import { isAllView, isSubscriptionsView } from './lib/utils/view-utils';
import useIsMobile from './hooks/use-is-mobile';
-import useTheme from './hooks/use-theme';
import styles from './app.module.css';
import Board from './views/board';
import Catalog from './views/catalog';
@@ -16,17 +14,19 @@ import ChallengeModal from './components/challenge-modal';
import PostForm from './components/post-form';
import SubplebbitStats from './components/subplebbit-stats';
import TopBar from './components/topbar';
+import { timeFilterNames } from './hooks/use-time-filter';
+import useTheme from './hooks/use-theme';
const BoardLayout = () => {
- const { accountCommentIndex, subplebbitAddress } = useParams();
+ const { accountCommentIndex, subplebbitAddress, timeFilterName } = useParams();
const location = useLocation();
const isMobile = useIsMobile();
- const isInAllView = isAllView(location.pathname);
- const isInSubscriptionsView = isSubscriptionsView(location.pathname);
+ const isInAllView = isAllView(location.pathname, useParams());
+ const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const isValidAccountCommentIndex = !accountCommentIndex || (!isNaN(parseInt(accountCommentIndex)) && parseInt(accountCommentIndex) >= 0);
- if (!isValidAccountCommentIndex) {
+ if (!isValidAccountCommentIndex || (timeFilterName && !timeFilterNames.includes(timeFilterName))) {
return ;
}
@@ -56,28 +56,22 @@ const BoardLayout = () => {
);
};
-const App = () => {
- const location = useLocation();
- const isInHomeView = isHomeView(location.pathname);
- const [theme] = useTheme();
+const GlobalLayout = () => {
+ useTheme();
- useEffect(() => {
- document.body.classList.forEach((className) => document.body.classList.remove(className));
- const classToAdd = isInHomeView ? 'yotsuba' : theme;
- document.body.classList.add(classToAdd);
- }, [theme, isInHomeView]);
-
- const globalLayout = (
+ return (
<>
>
);
+};
+const App = () => {
return (
-
+ }>
} />
}>
} />
diff --git a/src/components/board-buttons/board-buttons.tsx b/src/components/board-buttons/board-buttons.tsx
index 73d9eb2d..3a83ccb9 100644
--- a/src/components/board-buttons/board-buttons.tsx
+++ b/src/components/board-buttons/board-buttons.tsx
@@ -144,11 +144,11 @@ export const TimeFilter = ({ isInAllView, isInCatalogView, isInSubscriptionsView
export const MobileBoardButtons = () => {
const params = useParams();
const location = useLocation();
- const isInAllView = isAllView(location.pathname);
+ const isInAllView = isAllView(location.pathname, params);
const isInCatalogView = isCatalogView(location.pathname, params);
const isInPendingPostPage = isPendingPostView(location.pathname, params);
const isInPostView = isPostPageView(location.pathname, params);
- const isInSubscriptionsView = isSubscriptionsView(location.pathname);
+ const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const accountComment = useAccountComment({ commentIndex: params?.accountCommentIndex as any });
const subplebbitAddress = params?.subplebbitAddress || accountComment?.subplebbitAddress;
@@ -190,10 +190,10 @@ export const DesktopBoardButtons = () => {
const accountComment = useAccountComment({ commentIndex: params?.accountCommentIndex as any });
const subplebbitAddress = params?.subplebbitAddress || accountComment?.subplebbitAddress;
const isInCatalogView = isCatalogView(location.pathname, params);
- const isInAllView = isAllView(location.pathname);
+ const isInAllView = isAllView(location.pathname, params);
const isInPendingPostPage = isPendingPostView(location.pathname, params);
const isInPostView = isPostPageView(location.pathname, params);
- const isInSubscriptionsView = isSubscriptionsView(location.pathname);
+ const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
return (
<>
diff --git a/src/components/board-header/board-header.tsx b/src/components/board-header/board-header.tsx
index 879a56ba..0227ac26 100644
--- a/src/components/board-header/board-header.tsx
+++ b/src/components/board-header/board-header.tsx
@@ -20,8 +20,8 @@ const BoardHeader = () => {
const location = useLocation();
const params = useParams();
- const isInAllView = isAllView(location.pathname);
- const isInSubscriptionsView = isSubscriptionsView(location.pathname);
+ const isInAllView = isAllView(location.pathname, params);
+ const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const accountComment = useAccountComment({ commentIndex: params?.accountCommentIndex as any });
const subplebbitAddress = params?.subplebbitAddress || accountComment?.subplebbitAddress;
diff --git a/src/components/catalog-row/catalog-row.tsx b/src/components/catalog-row/catalog-row.tsx
index 4a00693c..5dacf149 100644
--- a/src/components/catalog-row/catalog-row.tsx
+++ b/src/components/catalog-row/catalog-row.tsx
@@ -1,7 +1,7 @@
import { useEffect, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
import { useTranslation } from 'react-i18next';
-import { Link, useLocation } from 'react-router-dom';
+import { Link, useLocation, useParams } from 'react-router-dom';
import { Comment, useComment } from '@plebbit/plebbit-react-hooks';
import { useFloating, offset, shift, size, autoUpdate, Placement } from '@floating-ui/react';
import { getCommentMediaInfo, getHasThumbnail } from '../../lib/utils/media-utils';
@@ -106,7 +106,7 @@ const CatalogPost = ({ post }: { post: Comment }) => {
const { hidden } = useHide({ cid });
const location = useLocation();
- const isInAllView = isAllView(location.pathname);
+ const isInAllView = isAllView(location.pathname, useParams());
const postLink = isInAllView && isDescription ? `/p/all/description` : `/p/${subplebbitAddress}/${isDescription ? 'description' : isRules ? 'rules' : `c/${cid}`}`;
diff --git a/src/components/edit-menu/edit-menu.tsx b/src/components/edit-menu/edit-menu.tsx
index df1fe233..d1b092b9 100644
--- a/src/components/edit-menu/edit-menu.tsx
+++ b/src/components/edit-menu/edit-menu.tsx
@@ -112,7 +112,6 @@ const EditMenu = ({ commentCid, isAccountMod, isAccountCommentAuthor, isCommentA
const headingId = useId();
const _publishCommentEdit = async () => {
- console.log('publishCommentEditOptions', publishCommentEditOptions);
try {
await publishCommentEdit();
} catch (error) {
diff --git a/src/components/markdown/markdown.tsx b/src/components/markdown/markdown.tsx
index 7bac056a..72b9fdcf 100644
--- a/src/components/markdown/markdown.tsx
+++ b/src/components/markdown/markdown.tsx
@@ -128,7 +128,7 @@ interface MarkdownProps {
title?: string;
}
-const Markdown = ({ content, spoiler, title }: MarkdownProps) => {
+const Markdown = ({ content, title }: MarkdownProps) => {
const remarkPlugins: any[] = [[supersub]];
if (content && content.length <= MAX_LENGTH_FOR_GFM) {
@@ -164,7 +164,7 @@ const Markdown = ({ content, spoiler, title }: MarkdownProps) => {
remarkPlugins={remarkPlugins}
rehypePlugins={[[rehypeSanitize, customSchema]]}
components={{
- p: ({ children }) => {spoiler ? {children} : children}
,
+ p: ({ children }) => {children}
,
img: ({ src }) => {src},
video: ({ src }) => {src},
iframe: ({ src }) => {src},
diff --git a/src/components/post-desktop/post-desktop.tsx b/src/components/post-desktop/post-desktop.tsx
index 09b3071e..97c4fcc8 100644
--- a/src/components/post-desktop/post-desktop.tsx
+++ b/src/components/post-desktop/post-desktop.tsx
@@ -34,9 +34,9 @@ const PostInfo = ({ openReplyModal, post, roles, isHidden }: PostProps) => {
const params = useParams();
const location = useLocation();
- const isInAllView = isAllView(location.pathname);
+ const isInAllView = isAllView(location.pathname, params);
const isInPostView = isPostPageView(location.pathname, params);
- const isInSubscriptionsView = isSubscriptionsView(location.pathname);
+ const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const shortDisplayName = displayName?.trim().length > 20 ? displayName?.trim().slice(0, 20).trim() + '...' : displayName?.trim();
const authorRole = roles?.[address]?.role;
diff --git a/src/components/post-desktop/post-menu-desktop/post-menu-desktop.tsx b/src/components/post-desktop/post-menu-desktop/post-menu-desktop.tsx
index 80313368..e867d882 100644
--- a/src/components/post-desktop/post-menu-desktop/post-menu-desktop.tsx
+++ b/src/components/post-desktop/post-menu-desktop/post-menu-desktop.tsx
@@ -134,10 +134,10 @@ const PostMenuDesktop = ({ post }: { post: Comment }) => {
const location = useLocation();
const params = useParams();
- const isInAllView = isAllView(location.pathname);
+ const isInAllView = isAllView(location.pathname, params);
const isInCatalogView = isCatalogView(location.pathname, params);
const isInPostPageView = isPostPageView(location.pathname, params);
- const isInSubscriptionsView = isSubscriptionsView(location.pathname);
+ const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const { refs, floatingStyles, context } = useFloating({
placement: 'bottom-start',
diff --git a/src/components/post-form/post-form.tsx b/src/components/post-form/post-form.tsx
index f9718be4..a66cb6f1 100644
--- a/src/components/post-form/post-form.tsx
+++ b/src/components/post-form/post-form.tsx
@@ -77,8 +77,8 @@ const PostFormTable = ({ closeForm }: { closeForm: () => void }) => {
const subjectRef = useRef(null);
const location = useLocation();
- const isInAllView = isAllView(location.pathname);
- const isInSubscriptionsView = isSubscriptionsView(location.pathname);
+ const isInAllView = isAllView(location.pathname, useParams());
+ const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const subscriptions = account?.subscriptions || [];
const defaultSubplebbitAddresses = useDefaultSubplebbitAddresses();
@@ -262,8 +262,8 @@ const PostForm = () => {
const isInDescriptionView = isDescriptionView(location.pathname, params);
const isInPostView = isPostPageView(location.pathname, params);
const isInRulesView = isRulesView(location.pathname, params);
- const isInAllView = isAllView(location.pathname);
- const isInSubscriptionsView = isSubscriptionsView(location.pathname);
+ const isInAllView = isAllView(location.pathname, params);
+ const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const comment = useComment({ commentCid: useParams().commentCid });
const { deleted, locked, removed } = comment || {};
diff --git a/src/components/post-mobile/post-mobile.tsx b/src/components/post-mobile/post-mobile.tsx
index fd1d956e..3805e299 100644
--- a/src/components/post-mobile/post-mobile.tsx
+++ b/src/components/post-mobile/post-mobile.tsx
@@ -26,8 +26,8 @@ const PostInfoAndMedia = ({ openReplyModal, post, roles }: PostProps) => {
const { address, displayName, shortAddress } = author || {};
const location = useLocation();
- const isInAllView = isAllView(location.pathname);
- const isInSubscriptionsView = isSubscriptionsView(location.pathname);
+ const isInAllView = isAllView(location.pathname, useParams());
+ const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const authorRole = roles?.[address]?.role;
const shortDisplayName = displayName?.trim().length > 20 ? displayName?.trim().slice(0, 20).trim() + '...' : displayName?.trim();
@@ -196,7 +196,7 @@ const PostMobile = ({ openReplyModal, post, roles, showAllReplies, showReplies =
const { isDescription, isRules } = post || {}; // custom properties, not from api
const params = useParams();
const location = useLocation();
- const isInAllView = isAllView(location.pathname);
+ const isInAllView = isAllView(location.pathname, params);
const isInPendingPostView = isPendingPostView(location.pathname, params);
const isInPostView = isPostPageView(location.pathname, params);
const linksCount = useCountLinksInReplies(post);
diff --git a/src/components/reply-modal/reply-modal.tsx b/src/components/reply-modal/reply-modal.tsx
index b53a38bc..77a28ced 100644
--- a/src/components/reply-modal/reply-modal.tsx
+++ b/src/components/reply-modal/reply-modal.tsx
@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react';
import { useLocation, useParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import Draggable from 'react-draggable';
-import { setAccount, useAccount, useSubplebbit } from '@plebbit/plebbit-react-hooks';
+import { setAccount, useAccount, useAuthorAddress, useSubplebbit } from '@plebbit/plebbit-react-hooks';
import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js';
import { getFormattedTimeAgo } from '../../lib/utils/time-utils';
import { isValidURL } from '../../lib/utils/url-utils';
@@ -78,8 +78,8 @@ const ReplyModal = ({ closeModal, parentCid, scrollY }: ReplyModalProps) => {
}, [parentCid]);
const location = useLocation();
- const isInAllView = isAllView(location.pathname);
- const isInSubscriptionsView = isSubscriptionsView(location.pathname);
+ const isInAllView = isAllView(location.pathname, useParams());
+ const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const subplebbit = useSubplebbit({ subplebbitAddress });
const { updatedAt } = subplebbit || {};
const isBoardOffline = subplebbit?.updatedAt && subplebbit.updatedAt < Date.now() / 1000 - 60 * 60;
diff --git a/src/components/settings-modal/interface-settings/interface-settings.tsx b/src/components/settings-modal/interface-settings/interface-settings.tsx
index 70502659..cf9494eb 100644
--- a/src/components/settings-modal/interface-settings/interface-settings.tsx
+++ b/src/components/settings-modal/interface-settings/interface-settings.tsx
@@ -65,8 +65,12 @@ const CheckForUpdates = () => {
const Style = () => {
const [theme, setTheme] = useTheme();
+ const handleThemeChange = (e: React.ChangeEvent) => {
+ setTheme(e.target.value);
+ };
+
return (
-