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 { 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: {

View File

@ -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 },
)
)

View File

@ -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 (
<ErrorBoundary fallback={(_err) => <FourOuFourView />}>
<Suspense fallback={<Loading />}>