added checking if coming from index
This commit is contained in:
parent
c936ed3dcb
commit
ef6aa48859
|
@ -1,6 +1,6 @@
|
|||
import { Link } from "@remix-run/react";
|
||||
|
||||
export function ThreadReply({ post, setReplying }) {
|
||||
export function ThreadReply({ post, setReplying, index }) {
|
||||
return (
|
||||
<li
|
||||
id={`${post.id}`}
|
||||
|
@ -15,7 +15,7 @@ export function ThreadReply({ post, setReplying }) {
|
|||
<Link
|
||||
className="mx-2 text-ctp-rosewater hover:text-ctp-maroon hover:underline"
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
index ? "" : event.preventDefault();
|
||||
document.getElementById(`bottom`).scrollIntoView(true);
|
||||
setReplying(post.id);
|
||||
}}
|
||||
|
@ -28,7 +28,7 @@ export function ThreadReply({ post, setReplying }) {
|
|||
<li key={reply.id}>
|
||||
<Link
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
index ? "" : event.preventDefault();
|
||||
document.getElementById(`${reply.id}`).scrollIntoView(true);
|
||||
}}
|
||||
className="text-ctp-teal hover:text-ctp-sky hover:underline"
|
||||
|
@ -43,11 +43,11 @@ export function ThreadReply({ post, setReplying }) {
|
|||
{post.replyingTo ? (
|
||||
<Link
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
index ? "" : event.preventDefault();
|
||||
document.getElementById(`${post.replyingTo}`).scrollIntoView(true);
|
||||
}}
|
||||
className="text-sm font-semibold hover:underline"
|
||||
to={`#${post.replyingTo}`}
|
||||
to={`/threads/${post.postId}#${post.replyingTo}`}
|
||||
>
|
||||
Replying to id: {post.replyingTo}
|
||||
</Link>
|
||||
|
|
|
@ -244,7 +244,11 @@ export default function Index() {
|
|||
thread.posts
|
||||
.slice(-3)
|
||||
.map((post) => (
|
||||
<ThreadReply key={post.id} post={post} />
|
||||
<ThreadReply
|
||||
index={true}
|
||||
key={post.id}
|
||||
post={post}
|
||||
/>
|
||||
))
|
||||
) : (
|
||||
<li>post has no replies yet...</li>
|
||||
|
|
|
@ -198,7 +198,12 @@ export default function Thread() {
|
|||
</div>
|
||||
<ul className="m-8 ">
|
||||
{data.posts.map((post) => (
|
||||
<ThreadReply key={post.id} setReplying={setReplying} post={post} />
|
||||
<ThreadReply
|
||||
key={post.id}
|
||||
setReplying={setReplying}
|
||||
index={false}
|
||||
post={post}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue