login fixes
This commit is contained in:
@@ -52,6 +52,9 @@ export default function PostForm(props: PostFormProps) {
|
||||
props.initialData?.body
|
||||
);
|
||||
const [hasSaved, setHasSaved] = createSignal(props.mode === "edit");
|
||||
const [createdPostId, setCreatedPostId] = createSignal<number | undefined>(
|
||||
props.postId
|
||||
);
|
||||
|
||||
// Mark initial load as complete after data is loaded (for edit mode)
|
||||
createEffect(() => {
|
||||
@@ -75,12 +78,13 @@ export default function PostForm(props: PostFormProps) {
|
||||
)) as string;
|
||||
}
|
||||
|
||||
if (props.mode === "edit") {
|
||||
if (props.mode === "edit" || createdPostId()) {
|
||||
// Update existing post (either in edit mode or if already created)
|
||||
await api.database.updatePost.mutate({
|
||||
id: props.postId!,
|
||||
id: createdPostId() || props.postId!,
|
||||
title: titleVal.replaceAll(" ", "_"),
|
||||
subtitle: subtitle() || "",
|
||||
body: body() || "",
|
||||
body: body() || "Hello, World!",
|
||||
banner_photo:
|
||||
bannerImageKey !== ""
|
||||
? bannerImageKey
|
||||
@@ -92,20 +96,19 @@ export default function PostForm(props: PostFormProps) {
|
||||
author_id: props.userID
|
||||
});
|
||||
} else {
|
||||
// Create mode: only save once
|
||||
if (!hasSaved()) {
|
||||
await api.database.createPost.mutate({
|
||||
category: "blog",
|
||||
title: titleVal.replaceAll(" ", "_"),
|
||||
subtitle: subtitle() || null,
|
||||
body: body() || null,
|
||||
banner_photo: bannerImageKey !== "" ? bannerImageKey : null,
|
||||
published: published(),
|
||||
tags: tags().length > 0 ? tags() : null,
|
||||
author_id: props.userID
|
||||
});
|
||||
setHasSaved(true);
|
||||
}
|
||||
// Create mode: only save once (first autosave)
|
||||
const result = await api.database.createPost.mutate({
|
||||
category: "blog",
|
||||
title: titleVal.replaceAll(" ", "_"),
|
||||
subtitle: subtitle() || null,
|
||||
body: body() || "Hello, World!",
|
||||
banner_photo: bannerImageKey !== "" ? bannerImageKey : null,
|
||||
published: published(),
|
||||
tags: tags().length > 0 ? tags() : null,
|
||||
author_id: props.userID
|
||||
});
|
||||
setCreatedPostId(result.data as number);
|
||||
setHasSaved(true);
|
||||
}
|
||||
|
||||
showAutoSaveTrigger();
|
||||
@@ -216,12 +219,13 @@ export default function PostForm(props: PostFormProps) {
|
||||
)) as string;
|
||||
}
|
||||
|
||||
if (props.mode === "edit") {
|
||||
if (props.mode === "edit" || createdPostId()) {
|
||||
// Update existing post (either in edit mode or if autosave created it)
|
||||
await api.database.updatePost.mutate({
|
||||
id: props.postId!,
|
||||
id: createdPostId() || props.postId!,
|
||||
title: title().replaceAll(" ", "_"),
|
||||
subtitle: subtitle() || null,
|
||||
body: body() || null,
|
||||
body: body() || "Hello, World!",
|
||||
banner_photo:
|
||||
bannerImageKey !== ""
|
||||
? bannerImageKey
|
||||
@@ -233,16 +237,18 @@ export default function PostForm(props: PostFormProps) {
|
||||
author_id: props.userID
|
||||
});
|
||||
} else {
|
||||
await api.database.createPost.mutate({
|
||||
// Create new post
|
||||
const result = await api.database.createPost.mutate({
|
||||
category: "blog",
|
||||
title: title().replaceAll(" ", "_"),
|
||||
subtitle: subtitle() || null,
|
||||
body: body() || null,
|
||||
body: body() || "Hello, World!",
|
||||
banner_photo: bannerImageKey !== "" ? bannerImageKey : null,
|
||||
published: published(),
|
||||
tags: tags().length > 0 ? tags() : null,
|
||||
author_id: props.userID
|
||||
});
|
||||
setCreatedPostId(result.data as number);
|
||||
}
|
||||
|
||||
navigate(`/blog/${encodeURIComponent(title().replaceAll(" ", "_"))}`);
|
||||
|
||||
@@ -1382,7 +1382,7 @@ export default function TextEditor(props: TextEditorProps) {
|
||||
{/* Language Selector Dropdown */}
|
||||
<Show when={showLanguageSelector()}>
|
||||
<div
|
||||
class="language-selector bg-mantle text-text border-surface2 fixed z-[110] max-h-64 w-48 overflow-y-auto rounded border shadow-lg"
|
||||
class="language-selector bg-mantle text-text border-surface2 fixed z-110 max-h-64 w-48 overflow-y-auto rounded border shadow-lg"
|
||||
style={{
|
||||
top: `${languageSelectorPosition().top}px`,
|
||||
left: `${languageSelectorPosition().left}px`
|
||||
@@ -1405,7 +1405,7 @@ export default function TextEditor(props: TextEditorProps) {
|
||||
{/* Table Grid Selector */}
|
||||
<Show when={showTableMenu()}>
|
||||
<div
|
||||
class="table-menu fixed z-[110]"
|
||||
class="table-menu fixed z-110"
|
||||
style={{
|
||||
top: `${tableMenuPosition().top}px`,
|
||||
left: `${tableMenuPosition().left}px`
|
||||
@@ -1418,7 +1418,7 @@ export default function TextEditor(props: TextEditorProps) {
|
||||
{/* Mermaid Template Selector */}
|
||||
<Show when={showMermaidTemplates()}>
|
||||
<div
|
||||
class="mermaid-menu bg-mantle text-text border-surface2 fixed z-[110] max-h-96 w-56 overflow-y-auto rounded border shadow-lg"
|
||||
class="mermaid-menu bg-mantle text-text border-surface2 fixed z-110 max-h-96 w-56 overflow-y-auto rounded border shadow-lg"
|
||||
style={{
|
||||
top: `${mermaidMenuPosition().top}px`,
|
||||
left: `${mermaidMenuPosition().left}px`
|
||||
@@ -1897,11 +1897,11 @@ export default function TextEditor(props: TextEditorProps) {
|
||||
{/* Keyboard Help Modal */}
|
||||
<Show when={showKeyboardHelp()}>
|
||||
<div
|
||||
class="bg-opacity-50 fixed inset-0 z-[110] flex items-center justify-center bg-black"
|
||||
class="bg-opacity-50 fixed inset-0 z-110 flex items-center justify-center bg-black"
|
||||
onClick={() => setShowKeyboardHelp(false)}
|
||||
>
|
||||
<div
|
||||
class="bg-base border-surface2 max-h-[80vh] w-full max-w-2xl overflow-y-auto rounded-lg border p-6 shadow-2xl"
|
||||
class="bg-base border-surface2 max-h-[80dvh] w-full max-w-2xl overflow-y-auto rounded-lg border p-6 shadow-2xl"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
{/* Header */}
|
||||
|
||||
Reference in New Issue
Block a user