From a59ee6260cffb8ed8277f76a243c1d440a261352 Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 7 Mar 2024 13:03:19 +0300 Subject: [PATCH] create-fx-fix --- src/pages/edit.page.tsx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/pages/edit.page.tsx b/src/pages/edit.page.tsx index 0feb07e1..8ed436a5 100644 --- a/src/pages/edit.page.tsx +++ b/src/pages/edit.page.tsx @@ -1,4 +1,4 @@ -import { Show, Suspense, createMemo, createSignal, lazy, onMount } from 'solid-js' +import { Show, Suspense, createEffect, createMemo, createSignal, lazy, on, onMount } from 'solid-js' import { AuthGuard } from '../components/AuthGuard' import { Loading } from '../components/_shared/Loading' @@ -24,16 +24,18 @@ export const EditPage = () => { const [shout, setShout] = createSignal(null) - onMount(async () => { - const { shout: loadedShout, error } = await apiClient.getMyShout(shoutId()) - console.log(loadedShout) - if (error) { - await snackbar?.showSnackbar({ type: 'error', body: t('This content is not published yet') }) - redirectPage(router, 'drafts') - } else { - setShout(loadedShout) - } - }) + createEffect( + on(shoutId, async (shout_id) => { + const { shout: loadedShout, error } = await apiClient.getMyShout(shout_id) + console.log(loadedShout) + if (error) { + await snackbar?.showSnackbar({ type: 'error', body: t('This content is not published yet') }) + redirectPage(router, 'drafts') + } else { + setShout(loadedShout) + } + }), + ) const title = createMemo(() => { if (!shout()) {