author-page-view

This commit is contained in:
Untone 2024-07-13 10:02:05 +03:00
parent b7e775eeea
commit 0192acb8a4
3 changed files with 23 additions and 19 deletions

View File

@ -1,5 +1,5 @@
import { SolidStartInlineConfig, defineConfig } from '@solidjs/start/config' 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 mkcert from 'vite-plugin-mkcert'
import { nodePolyfills } from 'vite-plugin-node-polyfills' import { nodePolyfills } from 'vite-plugin-node-polyfills'
import sassDts from 'vite-plugin-sass-dts' import sassDts from 'vite-plugin-sass-dts'
@ -48,7 +48,7 @@ export default defineConfig({
chunkSizeWarningLimit: 1024, chunkSizeWarningLimit: 1024,
target: 'esnext', target: 'esnext',
rollupOptions: { rollupOptions: {
plugins: [visualizer(), ] plugins: [visualizer()]
} }
}, },
server: { server: {

View File

@ -80,22 +80,26 @@ export const AuthorView = (props: Props) => {
// 1 // проверяет не собственный ли это профиль, иначе - загружает // 1 // проверяет не собственный ли это профиль, иначе - загружает
const [isFetching, setIsFetching] = createSignal(false) const [isFetching, setIsFetching] = createSignal(false)
createEffect( createEffect(
on([() => session()?.user?.app_data?.profile, () => props.authorSlug || ''], async ([me, slug]) => { on(
console.debug('check if my profile') [() => session()?.user?.app_data?.profile, () => props.authorSlug || ''],
const my = slug && me?.slug === slug async ([me, slug]) => {
if (my) { console.debug('check if my profile')
console.debug('[Author] my profile precached') const my = slug && me?.slug === slug
if (me) { if (my) {
setAuthor(me) console.debug('[Author] my profile precached')
if (myFollowers()) setFollowers((myFollowers() || []) as Author[]) if (me) {
changeFollowing([...(myFollows?.topics || []), ...(myFollows?.authors || [])]) 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) { defer: true }
await loadAuthor({ slug }) )
setIsFetching(false) // Сброс состояния загрузки после завершения
}
}, {defer: true})
) )
// 2 // догружает подписки автора // 2 // догружает подписки автора
@ -132,7 +136,7 @@ export const AuthorView = (props: Props) => {
const ccc = await commentsFetcher() const ccc = await commentsFetcher()
if (ccc) setCommented((_) => ccc || []) if (ccc) setCommented((_) => ccc || [])
} }
}, }
// { defer: true }, // { defer: true },
) )
) )

View File

@ -79,7 +79,7 @@ export default (props: RouteSectionProps<{ articles: Shout[]; author: Author; to
: getImageUrl('production/image/logo_image.png') : 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 ( return (
<ErrorBoundary fallback={(_err) => <FourOuFourView />}> <ErrorBoundary fallback={(_err) => <FourOuFourView />}>
<Suspense fallback={<Loading />}> <Suspense fallback={<Loading />}>