Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions frontend/screen/MovieChosenScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { useAuth } from '../context/AuthContext';
import type { components } from '../types/api-generated';
import { t } from '../il8n/_il8n';
import { UiTextKey } from '../il8n/_keys';
import { getUserProfile } from '../services/userService';

type MovieChosenScreenProps = {
movieId: string;
Expand Down Expand Up @@ -123,6 +124,33 @@ export default function MovieChosenScreen({ movieId }: MovieChosenScreenProps) {
}
}, [movieId]);

// Initialize spoiler toggle from user profile preference
useEffect(() => {
const loadSpoilerPreference = async () => {
try {
const res = await getUserProfile();
const profile = res?.userProfile;

if (!profile) {
console.log('No userProfile found');
return;
}

const pref = (profile as any).spoiler;

console.log('Loaded spoiler pref from profile:', pref);

if (typeof pref === 'boolean') {
setShowSpoilers(pref);
}
} catch (err) {
console.log('Failed to load spoiler preference:', err);
}
};

loadSpoilerPreference();
}, []);

// Auto-generate summary when movieId changes
useEffect(() => {
const generateSummary = async () => {
Expand Down Expand Up @@ -275,8 +303,8 @@ export default function MovieChosenScreen({ movieId }: MovieChosenScreenProps) {
// Unified spoiler flag for this post
const containsSpoilers = Boolean(
(post as any).containsSpoilers ??
(post as any).hasSpoilers ??
(post as any).spoiler
(post as any).hasSpoilers ??
(post as any).spoiler
);

// Is this post allowed to be fully visible?
Expand Down
Loading