Add preliminary settings schema

environments/review-settings-z-nejgds/deployments/3657
Alex Gleason 2023-07-20 18:38:01 -05:00
rodzic 4c3f3a6bdd
commit d69d9a34b4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 39 dodań i 2 usunięć

Wyświetl plik

@ -26,7 +26,7 @@ const importMessagesWithCustom = (locale: string): Promise<MessageJson> => {
});
};
const locales: string[] = [
const locales = [
'ar',
'ast',
'bg',
@ -91,7 +91,7 @@ const locales: string[] = [
'zh-CN',
'zh-HK',
'zh-TW',
];
] as const;
/** Soapbox locales map */
const messages = locales.reduce((acc, locale) => {
@ -100,3 +100,4 @@ const messages = locales.reduce((acc, locale) => {
}, {} as Record<string, () => Promise<MessageJson>>);
export default messages;
export { locales };

Wyświetl plik

@ -0,0 +1,36 @@
import { z } from 'zod';
import { locales } from 'soapbox/locales/messages';
const skinToneSchema = z.union([
z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(5), z.literal(6),
]);
const settingsSchema = z.object({
onboarded: z.boolean().catch(false),
skinTone: skinToneSchema.catch(1),
reduceMotion: z.boolean().catch(false),
underlineLinks: z.boolean().catch(false),
autoPlayGif: z.boolean().catch(true),
displayMedia: z.enum(['default', 'hide_all', 'show_all']).catch('default'),
expandSpoilers: z.boolean().catch(false),
unfollowModal: z.boolean().catch(false),
boostModal: z.boolean().catch(false),
deleteModal: z.boolean().catch(true),
missingDescriptionModal: z.boolean().catch(false),
defaultPrivacy: z.enum(['public', 'unlisted', 'private', 'direct']).catch('public'),
defaultContentType: z.enum(['text/plain', 'text/markdown']).catch('text/plain'),
themeMode: z.enum(['system', 'light', 'dark']).catch('system'),
locale: z.string().catch(navigator.language).pipe(z.enum(locales)).catch('en'),
showExplanationBox: z.boolean().catch(true),
explanationBox: z.boolean().catch(true),
autoloadTimelines: z.boolean().catch(true),
autoloadMore: z.boolean().catch(true),
systemFont: z.boolean().catch(false),
demetricator: z.boolean().catch(false),
isDeveloper: z.boolean().catch(false),
});
type Settings = z.infer<typeof settingsSchema>;
export { settingsSchema, type Settings };