conditional rendering of new comment added, typo corrected
This commit is contained in:
parent
39df975b04
commit
79208cb9c2
2 changed files with 7 additions and 4 deletions
|
@ -8,7 +8,7 @@ export function NewPostInputArea(): JSXElement {
|
||||||
const [content, setContent] = createSignal("");
|
const [content, setContent] = createSignal("");
|
||||||
const [waiting, setWaiting] = createSignal(false);
|
const [waiting, setWaiting] = createSignal(false);
|
||||||
|
|
||||||
// We assumte this context is always available
|
// We assume this context is always available
|
||||||
const login_ctx = useContext(LoginContext)!;
|
const login_ctx = useContext(LoginContext)!;
|
||||||
|
|
||||||
const nav = useNavigate();
|
const nav = useNavigate();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { useParams } from "@solidjs/router";
|
import { useParams } from "@solidjs/router";
|
||||||
import { JSXElement, Show, Suspense, createResource } from "solid-js";
|
import { JSXElement, Show, Suspense, createResource, useContext } from "solid-js";
|
||||||
|
import { LoginContext } from "../Context/GlobalState";
|
||||||
import { loadSpinner } from "../Util/Icons";
|
import { loadSpinner } from "../Util/Icons";
|
||||||
import { getPost } from "../Util/api";
|
import { getPost } from "../Util/api";
|
||||||
import { CommentSection } from "./CommentSection";
|
import { CommentSection } from "./CommentSection";
|
||||||
|
@ -10,12 +10,15 @@ import { NewCommentInputArea } from "./NewComment";
|
||||||
export function SinglePost(): JSXElement {
|
export function SinglePost(): JSXElement {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const [post] = createResource(params.postid, getPost);
|
const [post] = createResource(params.postid, getPost);
|
||||||
|
const login_ctx = useContext(LoginContext)!; // Assuming login context is always available
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={loadSpinner()}>
|
<Suspense fallback={loadSpinner()}>
|
||||||
<Show when={post()}>
|
<Show when={post()}>
|
||||||
<PostSegment post={post()!} />
|
<PostSegment post={post()!} />
|
||||||
<NewCommentInputArea parentPostId={parseInt(params.postid)}/>
|
<Show when={login_ctx.loggedIn()}>
|
||||||
|
<NewCommentInputArea parentPostId={parseInt(params.postid)}/>
|
||||||
|
</Show>
|
||||||
<CommentSection postId={params.postid} />
|
<CommentSection postId={params.postid} />
|
||||||
</Show>
|
</Show>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|
Loading…
Reference in a new issue