Fix reviews hidden during loading, update Review interface with user field
This commit is contained in:
parent
5b7d8da250
commit
bbcb935685
2 changed files with 17 additions and 13 deletions
|
|
@ -8,10 +8,17 @@ import { getApiUrl } from "@/lib/api-config"
|
||||||
interface Review {
|
interface Review {
|
||||||
id: number
|
id: number
|
||||||
user_id: number
|
user_id: number
|
||||||
blurb: string
|
blurb?: string | null
|
||||||
content: string
|
content?: string | null
|
||||||
score: number
|
score?: number | null
|
||||||
created_at: string
|
created_at: string
|
||||||
|
user?: {
|
||||||
|
id: number
|
||||||
|
username: string
|
||||||
|
display_name?: string | null
|
||||||
|
avatar_bg_color?: string
|
||||||
|
avatar_text?: string | null
|
||||||
|
} | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export type EntityType = "show" | "venue" | "song" | "performance" | "tour" | "year"
|
export type EntityType = "show" | "venue" | "song" | "performance" | "tour" | "year"
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,13 @@ interface SocialWrapperProps {
|
||||||
export function SocialWrapper({ type, children }: SocialWrapperProps) {
|
export function SocialWrapper({ type, children }: SocialWrapperProps) {
|
||||||
const { preferences, loading } = usePreferences()
|
const { preferences, loading } = usePreferences()
|
||||||
|
|
||||||
// Avoid flash of content or layout shift by checking loading?
|
// While loading, show content (assume defaults: wiki_mode=false, show_comments=true, show_ratings=true)
|
||||||
// For now, let's just return null if loading to be safe, or maybe render nothing until we know.
|
// Only hide once we know the user's preference is explicitly set to hide
|
||||||
if (loading) return null
|
if (!loading) {
|
||||||
|
|
||||||
if (preferences.wiki_mode) return null
|
if (preferences.wiki_mode) return null
|
||||||
|
|
||||||
if (type === "comments" && !preferences.show_comments) return null
|
if (type === "comments" && !preferences.show_comments) return null
|
||||||
if (type === "ratings" && !preferences.show_ratings) return null
|
if (type === "ratings" && !preferences.show_ratings) return null
|
||||||
// For reviews, we assume they are hidden if wiki_mode is on (handled above)
|
}
|
||||||
// or if we add a specific show_reviews preference later.
|
|
||||||
|
|
||||||
return <>{children}</>
|
return <>{children}</>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue