mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(pending post): show board navigation, stats and post form
This commit is contained in:
+7
-5
@@ -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>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const PendingPost = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isInSettingsView && <SettingsModal />}
|
{isInSettingsView && <SettingsModal />}
|
||||||
<Post post={post} showReplies={false} />
|
<Post post={post} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user