mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 06:31:13 -05:00
Fix settings validation and session errors
This commit is contained in:
@@ -60,19 +60,24 @@ export function PrivacyTab() {
|
||||
}
|
||||
|
||||
if (data?.privacy_settings) {
|
||||
// Validate the data before using it
|
||||
const validatedSettings = privacySettingsSchema.parse(data.privacy_settings);
|
||||
setPreferences(validatedSettings);
|
||||
|
||||
form.reset({
|
||||
privacy_level: (profile?.privacy_level === 'public' || profile?.privacy_level === 'private')
|
||||
? profile.privacy_level
|
||||
: 'public',
|
||||
show_pronouns: profile?.show_pronouns || false,
|
||||
...validatedSettings
|
||||
});
|
||||
const parseResult = privacySettingsSchema.safeParse(data.privacy_settings);
|
||||
|
||||
if (parseResult.success) {
|
||||
setPreferences(parseResult.data);
|
||||
form.reset({
|
||||
privacy_level: (profile?.privacy_level === 'public' || profile?.privacy_level === 'private')
|
||||
? profile.privacy_level
|
||||
: 'public',
|
||||
show_pronouns: profile?.show_pronouns || false,
|
||||
...parseResult.data
|
||||
});
|
||||
} else {
|
||||
console.warn('Invalid privacy settings, reinitializing with defaults', {
|
||||
errors: parseResult.error.issues
|
||||
});
|
||||
await initializePreferences();
|
||||
}
|
||||
} else {
|
||||
// Initialize preferences if they don't exist
|
||||
await initializePreferences();
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user