🐛 Bug fixes

This commit is contained in:
LittleSheep 2024-02-11 13:35:10 +08:00
parent a5d6071bef
commit 3a0daab641
3 changed files with 29 additions and 16 deletions

View File

@ -50,6 +50,7 @@ export default function PostEditor(props: {
setAttachments(props.editing?.attachments ?? []); setAttachments(props.editing?.attachments ?? []);
setCategories(props.editing?.categories ?? []); setCategories(props.editing?.categories ?? []);
setTags(props.editing?.tags ?? []); setTags(props.editing?.tags ?? []);
editor()?.setValue(props.editing?.content);
}, [props.editing]); }, [props.editing]);
async function listRealm() { async function listRealm() {
@ -146,6 +147,7 @@ export default function PostEditor(props: {
<div class="border-y border-base-200"> <div class="border-y border-base-200">
<PostEditActions <PostEditActions
editing={props.editing}
onInputAlias={setAlias} onInputAlias={setAlias}
onInputPublish={setPublishedAt} onInputPublish={setPublishedAt}
onInputAttachments={setAttachments} onInputAttachments={setAttachments}
@ -156,11 +158,20 @@ export default function PostEditor(props: {
</div> </div>
<div class="pt-3 pb-7 px-7"> <div class="pt-3 pb-7 px-7">
<Show when={!props.editing} fallback={
<label class="form-control w-full mb-3">
<div class="label">
<span class="label-text">Publish region</span>
</div>
<input readonly type="text" class="input input-bordered"
value={`You published this post in realm #${props.editing?.realm_id ?? "global"}`} />
</label>
}>
<label class="form-control w-full"> <label class="form-control w-full">
<div class="label"> <div class="label">
<span class="label-text">Publish region</span> <span class="label-text">Publish region</span>
</div> </div>
<select name="realm" class="select select-bordered" disabled={props.editing}> <select name="realm" class="select select-bordered">
<option value={0} selected>Global</option> <option value={0} selected>Global</option>
<For each={realmList()}> <For each={realmList()}>
{item => <option value={item.id}>{item.name}</option>} {item => <option value={item.id}>{item.name}</option>}
@ -170,6 +181,7 @@ export default function PostEditor(props: {
<span class="label-text-alt">Will show realms you joined or created.</span> <span class="label-text-alt">Will show realms you joined or created.</span>
</div> </div>
</label> </label>
</Show>
<label class="form-control w-full"> <label class="form-control w-full">
<div class="label"> <div class="label">

View File

@ -190,6 +190,7 @@ export default function PostPublish(props: {
<div id="publish-actions" class="flex justify-between border-y border-base-200"> <div id="publish-actions" class="flex justify-between border-y border-base-200">
<PostEditActions <PostEditActions
editing={props.editing}
onInputAlias={setAlias} onInputAlias={setAlias}
onInputPublish={setPublishedAt} onInputPublish={setPublishedAt}
onInputAttachments={setAttachments} onInputAttachments={setAttachments}

View File

@ -15,7 +15,7 @@ export default function PublishPost() {
headers: { "Authorization": `Bearer ${getAtk()}` } headers: { "Authorization": `Bearer ${getAtk()}` }
}); });
if (res.status === 200) { if (res.status === 200) {
setPost(await res.json()); setPost((await res.json())["data"]);
} else { } else {
setError(await res.text()); setError(await res.text());
} }
@ -30,7 +30,7 @@ export default function PublishPost() {
<i class="fa-solid fa-angle-left"></i> <i class="fa-solid fa-angle-left"></i>
</a> </a>
<div class="px-5 flex items-center"> <div class="px-5 flex items-center">
<p>Publish a new post</p> <p>Edit{post()?.title ? post()?.title : "Untitled"}</p>
</div> </div>
</div> </div>