From 500e8132dd5fabaab69aaf0d23de0d0fbd924889 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 6 May 2024 18:39:01 +0300 Subject: [PATCH 1/2] fix nav header --- src/components/Nav/HeaderAuth.tsx | 59 ++++++++++--------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/src/components/Nav/HeaderAuth.tsx b/src/components/Nav/HeaderAuth.tsx index a0c273fc..8556c77f 100644 --- a/src/components/Nav/HeaderAuth.tsx +++ b/src/components/Nav/HeaderAuth.tsx @@ -34,12 +34,12 @@ export const HeaderAuth = (props: Props) => { const { page } = useRouter() const { session, author, isSessionLoaded } = useSession() const { unreadNotificationsCount, showNotificationsPanel } = useNotifications() - const { form, toggleEditorPanel, saveShout, saveDraft, publishShout } = useEditorContext() + const { form, toggleEditorPanel, saveShout, publishShout } = useEditorContext() const handleBellIconClick = (event: Event) => { event.preventDefault() - if (!author()?.id) { + if (!session()?.access_token) { showModal('auth') return } @@ -48,23 +48,19 @@ export const HeaderAuth = (props: Props) => { } const isEditorPage = createMemo(() => page().route === 'edit' || page().route === 'editSettings') - const isNotificationsVisible = createMemo(() => author()?.id && !isEditorPage()) - const isSaveButtonVisible = createMemo(() => author()?.id && isEditorPage()) + const isNotificationsVisible = createMemo(() => session()?.access_token && !isEditorPage()) + const isSaveButtonVisible = createMemo(() => session()?.access_token && isEditorPage()) const isCreatePostButtonVisible = createMemo(() => !isEditorPage()) - const isAuthenticatedControlsVisible = createMemo(() => author()?.id && session()?.user?.email_verified) + const isAuthenticatedControlsVisible = createMemo( + () => session()?.access_token && session()?.user?.email_verified, + ) const handleBurgerButtonClick = () => { toggleEditorPanel() } - // FIXME: use or remove - const handleSaveClick = () => { - const hasTopics = form.selectedTopics?.length > 0 - if (hasTopics) { - saveShout(form) - } else { - saveDraft(form) - } + const handleSaveButtonClick = () => { + saveShout(form) } const [width, setWidth] = createSignal(0) @@ -110,14 +106,8 @@ export const HeaderAuth = (props: Props) => {