Added replies
This commit is contained in:
parent
1c75af5349
commit
e9723303d8
6 changed files with 54 additions and 14 deletions
|
@ -1,17 +1,19 @@
|
|||
<script>
|
||||
import { page } from '$app/stores'
|
||||
|
||||
import Area from '$lib/components/Area.svelte';
|
||||
import FileUpload from '$lib/components/FileUpload.svelte';
|
||||
import PostBody from '$lib/components/PostBody.svelte';
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
|
||||
import { handleSubmit, formatPost } from '$lib/util.js';;
|
||||
import { handleSubmit, formatPost } from '$lib/util.js';
|
||||
|
||||
/** @type {import('./$types').ActionData} */
|
||||
export let form;
|
||||
|
||||
let uploadForm = {};
|
||||
|
||||
let formContent = '';
|
||||
let formContent = $page.url.searchParams.get('init') || '';
|
||||
let formBody;
|
||||
|
||||
let currentState = 'editor';
|
||||
|
@ -48,8 +50,7 @@
|
|||
method='POST'
|
||||
on:submit|preventDefault={async e => form = JSON.parse(await handleSubmit(e)) }
|
||||
>
|
||||
<textarea name='content' style='display: none;' value={formContent}></textarea
|
||||
</form>
|
||||
<textarea name='content' style='display: none;' value={formContent}></textarea>
|
||||
<input formaction="?/create" type='submit' value='Post' bind:this={formBody} style='display: none;'>
|
||||
{#if currentState == 'editor'}
|
||||
<p>
|
||||
|
@ -60,6 +61,7 @@
|
|||
{:else}
|
||||
<FileUpload bind:form={uploadForm} />
|
||||
{/if}
|
||||
</form>
|
||||
</div>
|
||||
<span slot="footer">
|
||||
<div class='wrapper'>
|
||||
|
|
|
@ -4,11 +4,12 @@ import { redirect } from '@sveltejs/kit';
|
|||
export async function load({ fetch, params, url }) {
|
||||
|
||||
var id = params.post;
|
||||
var page = url.searchParams.get('page') * 1;
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
|
||||
const res = await fetch(`/api/postBulk?id=${id}`);
|
||||
const res = await fetch(`/api/postBulk?id=${id}&page=${page}`);
|
||||
const postJson = (await res.json());
|
||||
|
||||
return {postJson};
|
||||
return {postJson, id: page};
|
||||
}
|
|
@ -1,8 +1,24 @@
|
|||
<script>
|
||||
import PostList from '$lib/components/PostList.svelte';
|
||||
import Post from '$lib/components/Post.svelte';
|
||||
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data;
|
||||
|
||||
let firstEntry = data.postJson.data.shift();
|
||||
</script>
|
||||
|
||||
{#if firstEntry.username}
|
||||
<Post
|
||||
success={firstEntry.success}
|
||||
username={firstEntry.username}
|
||||
content={firstEntry.content}
|
||||
upvotes={firstEntry.upvotes}
|
||||
downvotes={firstEntry.downvotes}
|
||||
id={firstEntry.id}
|
||||
isAuthor={firstEntry.isAuthor}
|
||||
></Post>
|
||||
{/if}
|
||||
|
||||
<h2>Replies</h2>
|
||||
<PostList data={data} />
|
Loading…
Add table
Add a link
Reference in a new issue