feat(pending post): show board navigation, stats and post form

This commit is contained in:
Tom (plebeius.eth)
2024-08-29 14:18:20 +02:00
parent 74ddae0ed7
commit cdee29e94f
3 changed files with 11 additions and 11 deletions
+7 -5
View File
@@ -1,7 +1,10 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Outlet, Route, Routes, useLocation, useParams } from 'react-router-dom'; import { Outlet, Route, Routes, useLocation, useParams } from 'react-router-dom';
import { useAccountComment } from '@plebbit/plebbit-react-hooks';
import { isAllView, isSubscriptionsView } from './lib/utils/view-utils'; import { isAllView, isSubscriptionsView } from './lib/utils/view-utils';
import useIsMobile from './hooks/use-is-mobile'; import useIsMobile from './hooks/use-is-mobile';
import useTheme from './hooks/use-theme';
import { timeFilterNames } from './hooks/use-time-filter';
import styles from './app.module.css'; import styles from './app.module.css';
import Board from './views/board'; import Board from './views/board';
import Catalog from './views/catalog'; import Catalog from './views/catalog';
@@ -16,8 +19,6 @@ import ChallengeModal from './components/challenge-modal';
import PostForm from './components/post-form'; import PostForm from './components/post-form';
import SubplebbitStats from './components/subplebbit-stats'; import SubplebbitStats from './components/subplebbit-stats';
import TopBar from './components/topbar'; import TopBar from './components/topbar';
import { timeFilterNames } from './hooks/use-time-filter';
import useTheme from './hooks/use-theme';
const BoardLayout = () => { const BoardLayout = () => {
const { accountCommentIndex, subplebbitAddress, timeFilterName } = useParams(); const { accountCommentIndex, subplebbitAddress, timeFilterName } = useParams();
@@ -25,8 +26,9 @@ const BoardLayout = () => {
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const isInAllView = isAllView(location.pathname, useParams()); const isInAllView = isAllView(location.pathname, useParams());
const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams()); const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const pendingPost = useAccountComment({ commentIndex: accountCommentIndex ? parseInt(accountCommentIndex) : undefined });
const isValidAccountCommentIndex = !accountCommentIndex || (!isNaN(parseInt(accountCommentIndex)) && parseInt(accountCommentIndex) >= 0); const isValidAccountCommentIndex = !accountCommentIndex || (!isNaN(Number(accountCommentIndex)) && Number(accountCommentIndex) >= 0);
if (!isValidAccountCommentIndex || (timeFilterName && !timeFilterNames.includes(timeFilterName))) { if (!isValidAccountCommentIndex || (timeFilterName && !timeFilterNames.includes(timeFilterName))) {
return <NotFound />; return <NotFound />;
@@ -42,13 +44,13 @@ const BoardLayout = () => {
<TopBar /> <TopBar />
<BoardHeader /> <BoardHeader />
{isMobile {isMobile
? (subplebbitAddress || isInAllView || isInSubscriptionsView) && ( ? (subplebbitAddress || isInAllView || isInSubscriptionsView || pendingPost?.subplebbitAddress) && (
<> <>
<PostForm key={key} /> <PostForm key={key} />
<MobileBoardButtons /> <MobileBoardButtons />
</> </>
) )
: (subplebbitAddress || isInAllView || isInSubscriptionsView) && ( : (subplebbitAddress || isInAllView || isInSubscriptionsView || pendingPost?.subplebbitAddress) && (
<> <>
<PostForm key={key} /> <PostForm key={key} />
{!(isInAllView || isInSubscriptionsView) && <SubplebbitStats />} {!(isInAllView || isInSubscriptionsView) && <SubplebbitStats />}
@@ -267,11 +267,9 @@ export const DesktopBoardButtons = () => {
<ReturnButton address={subplebbitAddress} isInAllView={isInAllView} isInSubscriptionsView={isInSubscriptionsView} /> <ReturnButton address={subplebbitAddress} isInAllView={isInAllView} isInSubscriptionsView={isInSubscriptionsView} />
] [ ] [
<CatalogButton address={subplebbitAddress} isInAllView={isInAllView} isInSubscriptionsView={isInSubscriptionsView} />] <CatalogButton address={subplebbitAddress} isInAllView={isInAllView} isInSubscriptionsView={isInSubscriptionsView} />]
{isInPostView && ( <span className={styles.rightSideButtons}>
<span className={styles.rightSideButtons}> <PostPageStats />
<PostPageStats /> </span>
</span>
)}
</> </>
) : ( ) : (
<> <>
+1 -1
View File
@@ -28,7 +28,7 @@ const PendingPost = () => {
return ( return (
<> <>
{isInSettingsView && <SettingsModal />} {isInSettingsView && <SettingsModal />}
<Post post={post} showReplies={false} /> <Post post={post} />
</> </>
); );
}; };