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 [waiting, setWaiting] = createSignal(false);
|
||||
|
||||
// We assumte this context is always available
|
||||
// We assume this context is always available
|
||||
const login_ctx = useContext(LoginContext)!;
|
||||
|
||||
const nav = useNavigate();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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 { getPost } from "../Util/api";
|
||||
import { CommentSection } from "./CommentSection";
|
||||
|
@ -10,12 +10,15 @@ import { NewCommentInputArea } from "./NewComment";
|
|||
export function SinglePost(): JSXElement {
|
||||
const params = useParams();
|
||||
const [post] = createResource(params.postid, getPost);
|
||||
const login_ctx = useContext(LoginContext)!; // Assuming login context is always available
|
||||
|
||||
return (
|
||||
<Suspense fallback={loadSpinner()}>
|
||||
<Show when={post()}>
|
||||
<PostSegment post={post()!} />
|
||||
<Show when={login_ctx.loggedIn()}>
|
||||
<NewCommentInputArea parentPostId={parseInt(params.postid)}/>
|
||||
</Show>
|
||||
<CommentSection postId={params.postid} />
|
||||
</Show>
|
||||
</Suspense>
|
||||
|
|
Loading…
Reference in a new issue