feat: update session creation to hydrate data immediately
Update `createSession` to return the session ID, allowing the UI to automatically set the active session and trigger a server hydration immediately after creation. This ensures the UI reflects the new session state without a manual refresh.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* CreateSessionDialog — modal for naming a new session
|
||||
*/
|
||||
import { Component, createSignal, onMount } from "solid-js";
|
||||
import { createSession } from "../stores/journalStream";
|
||||
import { createSession, setSessionId, hydrateFromServer } from "../stores/journalStream";
|
||||
|
||||
interface CreateSessionDialogProps {
|
||||
onClose: () => void;
|
||||
@@ -12,13 +12,21 @@ export const CreateSessionDialog: Component<CreateSessionDialogProps> = (
|
||||
props,
|
||||
) => {
|
||||
const [name, setName] = createSignal("");
|
||||
const [creating, setCreating] = createSignal(false);
|
||||
let inputRef!: HTMLInputElement;
|
||||
|
||||
const handleCreate = () => {
|
||||
const handleCreate = async () => {
|
||||
const trimmed = name().trim();
|
||||
if (!trimmed) return;
|
||||
createSession(trimmed);
|
||||
setCreating(true);
|
||||
const id = createSession(trimmed);
|
||||
if (id) {
|
||||
setSessionId(id);
|
||||
// Hydrate the new (empty) session so the UI reflects it immediately
|
||||
await hydrateFromServer(id).catch(() => {});
|
||||
}
|
||||
setName("");
|
||||
setCreating(false);
|
||||
props.onClose();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user