added "/post" route render

This commit is contained in:
plebbitor
2023-03-06 14:33:31 +01:00
parent 4b9a1a8ed5
commit 55f9461ad2
3 changed files with 50 additions and 11 deletions
+15 -2
View File
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useContext } from 'react';
import { Link, useNavigate, useParams } from 'react-router-dom';
import { Link, useNavigate, useParams, useLocation } from 'react-router-dom';
import { BoardContext } from '../App';
import { Container, NavBar, Header, Break, PostFormLink, PostFormTable, PostForm, TopBar, BoardForm } from './styles/Board.styled';
import ImageBanner from './ImageBanner';
@@ -20,6 +20,7 @@ const Board = ({ setBodyStyle }) => {
const [comment, setComment] = useState('');
const { publishComment } = useAccountsActions();
const navigate = useNavigate();
const location = useLocation();
const [prevScrollPos, setPrevScrollPos] = useState(0);
const [visible, setVisible] = useState(true);
const [endIndex, setEndIndex] = useState(2);
@@ -80,6 +81,18 @@ const Board = ({ setBodyStyle }) => {
setEndIndex(2);
}, [selectedAddress]);
// post route handling
useEffect(() => {
const path = location.pathname;
if (path.endsWith('/post')) {
setShowPostFormLink(false);
setShowPostForm(true);
} else {
setShowPostFormLink(true);
setShowPostForm(false);
}
}, [location.pathname]);
const tryLoadMore = async () => {
@@ -540,7 +553,7 @@ const Board = ({ setBodyStyle }) => {
</div>
</div>
</div>
<span class="summary">
<span className="summary">
{omittedCount > 0 ? (
<span key={`oc-${thread.cid}`} className="ttl">
<span key={`oc1-${thread.cid}`}>