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 {
|
||||
id: number
|
||||
user_id: number
|
||||
blurb: string
|
||||
content: string
|
||||
score: number
|
||||
blurb?: string | null
|
||||
content?: string | null
|
||||
score?: number | null
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -10,16 +10,13 @@ interface SocialWrapperProps {
|
|||
export function SocialWrapper({ type, children }: SocialWrapperProps) {
|
||||
const { preferences, loading } = usePreferences()
|
||||
|
||||
// Avoid flash of content or layout shift by checking loading?
|
||||
// For now, let's just return null if loading to be safe, or maybe render nothing until we know.
|
||||
if (loading) return null
|
||||
|
||||
if (preferences.wiki_mode) return null
|
||||
|
||||
if (type === "comments" && !preferences.show_comments) 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.
|
||||
// While loading, show content (assume defaults: wiki_mode=false, show_comments=true, show_ratings=true)
|
||||
// Only hide once we know the user's preference is explicitly set to hide
|
||||
if (!loading) {
|
||||
if (preferences.wiki_mode) return null
|
||||
if (type === "comments" && !preferences.show_comments) return null
|
||||
if (type === "ratings" && !preferences.show_ratings) return null
|
||||
}
|
||||
|
||||
return <>{children}</>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue