From 0192acb8a46892774224b1265ee0335dbf4b6cc3 Mon Sep 17 00:00:00 2001 From: Untone Date: Sat, 13 Jul 2024 10:02:05 +0300 Subject: [PATCH] author-page-view --- app.config.ts | 4 +-- src/components/Views/Author/Author.tsx | 36 ++++++++++++++------------ src/routes/author/[slug]/[...tab].tsx | 2 +- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app.config.ts b/app.config.ts index c218dda3..7e43a2f2 100644 --- a/app.config.ts +++ b/app.config.ts @@ -1,5 +1,5 @@ import { SolidStartInlineConfig, defineConfig } from '@solidjs/start/config' -import { visualizer } from "rollup-plugin-visualizer" +import { visualizer } from 'rollup-plugin-visualizer' import mkcert from 'vite-plugin-mkcert' import { nodePolyfills } from 'vite-plugin-node-polyfills' import sassDts from 'vite-plugin-sass-dts' @@ -48,7 +48,7 @@ export default defineConfig({ chunkSizeWarningLimit: 1024, target: 'esnext', rollupOptions: { - plugins: [visualizer(), ] + plugins: [visualizer()] } }, server: { diff --git a/src/components/Views/Author/Author.tsx b/src/components/Views/Author/Author.tsx index f8f42836..42eef937 100644 --- a/src/components/Views/Author/Author.tsx +++ b/src/components/Views/Author/Author.tsx @@ -80,22 +80,26 @@ export const AuthorView = (props: Props) => { // 1 // проверяет не собственный ли это профиль, иначе - загружает const [isFetching, setIsFetching] = createSignal(false) createEffect( - on([() => session()?.user?.app_data?.profile, () => props.authorSlug || ''], async ([me, slug]) => { - console.debug('check if my profile') - const my = slug && me?.slug === slug - if (my) { - console.debug('[Author] my profile precached') - if (me) { - setAuthor(me) - if (myFollowers()) setFollowers((myFollowers() || []) as Author[]) - changeFollowing([...(myFollows?.topics || []), ...(myFollows?.authors || [])]) + on( + [() => session()?.user?.app_data?.profile, () => props.authorSlug || ''], + async ([me, slug]) => { + console.debug('check if my profile') + const my = slug && me?.slug === slug + if (my) { + console.debug('[Author] my profile precached') + if (me) { + setAuthor(me) + if (myFollowers()) setFollowers((myFollowers() || []) as Author[]) + changeFollowing([...(myFollows?.topics || []), ...(myFollows?.authors || [])]) + } + } else if (slug && !isFetching()) { + setIsFetching(true) + await loadAuthor({ slug }) + setIsFetching(false) // Сброс состояния загрузки после завершения } - } else if (slug && !isFetching()) { - setIsFetching(true) - await loadAuthor({ slug }) - setIsFetching(false) // Сброс состояния загрузки после завершения - } - }, {defer: true}) + }, + { defer: true } + ) ) // 2 // догружает подписки автора @@ -132,7 +136,7 @@ export const AuthorView = (props: Props) => { const ccc = await commentsFetcher() if (ccc) setCommented((_) => ccc || []) } - }, + } // { defer: true }, ) ) diff --git a/src/routes/author/[slug]/[...tab].tsx b/src/routes/author/[slug]/[...tab].tsx index 2ac239fb..647daa0d 100644 --- a/src/routes/author/[slug]/[...tab].tsx +++ b/src/routes/author/[slug]/[...tab].tsx @@ -79,7 +79,7 @@ export default (props: RouteSectionProps<{ articles: Shout[]; author: Author; to : getImageUrl('production/image/logo_image.png') ) - const selectedTab = createMemo(() => params.tab in ['followers', 'shouts'] ? params.tab : 'name') + const selectedTab = createMemo(() => (params.tab in ['followers', 'shouts'] ? params.tab : 'name')) return ( }> }>