Merge pull request #483 from Discours/hotfix/sv-author-empty
Author empty for logged in user (user profile)
This commit is contained in:
commit
9491f7c504
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
.devcontainer
|
||||
.pnpm-store
|
||||
dist/
|
||||
node_modules/
|
||||
npm-debug.log*
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/**
|
||||
* Placeholder component displays different placeholder content based on type and mode.
|
||||
*
|
||||
* @param {PlaceholderProps} props - The properties for the component.
|
||||
* @returns {JSX.Element | null} The rendered placeholder or null if data is missing.
|
||||
*/
|
||||
|
||||
import { clsx } from 'clsx'
|
||||
import { For, Show, createMemo } from 'solid-js'
|
||||
|
||||
|
@ -89,7 +96,21 @@ export const Placeholder = (props: PlaceholderProps) => {
|
|||
const { t } = useLocalize()
|
||||
const { session } = useSession()
|
||||
|
||||
const placeholderData = createMemo(() => data[props.type])
|
||||
// dufok (^-^') mem for placeholder data without a fallback, it will be `undefined` if not found
|
||||
|
||||
const placeholderData = createMemo(() => {
|
||||
const dataForType = data[props.type];
|
||||
if (!dataForType) {
|
||||
console.warn(`No placeholder data found for type: ${props.type}`);
|
||||
}
|
||||
return dataForType;
|
||||
// (^-^') No fallback to ensure it is empty when data is missing
|
||||
});
|
||||
|
||||
// (^-^') Return null if no placeholder data is found
|
||||
if (!placeholderData()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
|
@ -100,17 +121,17 @@ export const Placeholder = (props: PlaceholderProps) => {
|
|||
)}
|
||||
>
|
||||
<div class={styles.placeholderCover}>
|
||||
<img src={`/${placeholderData().image}`} alt={placeholderData().header} />
|
||||
<img src={`/${placeholderData()?.image}`} alt={placeholderData()?.header} />
|
||||
</div>
|
||||
<div class={styles.placeholderContent}>
|
||||
<div>
|
||||
<h3 innerHTML={t(placeholderData().header)} />
|
||||
<p innerHTML={t(placeholderData().text)} />
|
||||
<h3 innerHTML={t(placeholderData()?.header)} />
|
||||
<p innerHTML={t(placeholderData()?.text)} />
|
||||
</div>
|
||||
|
||||
<Show when={placeholderData().profileLinks}>
|
||||
<Show when={placeholderData()?.profileLinks}>
|
||||
<div class={styles.bottomLinks}>
|
||||
<For each={placeholderData().profileLinks}>
|
||||
<For each={placeholderData()?.profileLinks}>
|
||||
{(link) => (
|
||||
<a href={link.href}>
|
||||
<Icon name="link-white" class={styles.icon} />
|
||||
|
@ -133,7 +154,7 @@ export const Placeholder = (props: PlaceholderProps) => {
|
|||
</a>
|
||||
}
|
||||
>
|
||||
<a class={styles.button} href={placeholderData().href}>
|
||||
<a class={styles.button} href={placeholderData()?.href}>
|
||||
{t(
|
||||
session()?.access_token
|
||||
? placeholderData()?.buttonLabelAuthor || ''
|
||||
|
|
|
@ -133,7 +133,10 @@ export default function AuthorPage(props: RouteSectionProps<AuthorPageProps>) {
|
|||
)
|
||||
|
||||
return (
|
||||
<ErrorBoundary fallback={(_err) => <FourOuFourView />}>
|
||||
<ErrorBoundary fallback={(_err) => {
|
||||
console.error('ErrorBoundary caught an error', _err)
|
||||
return <FourOuFourView />
|
||||
}}>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<PageLayout
|
||||
title={title()}
|
||||
|
|
Loading…
Reference in New Issue
Block a user