diff --git a/app/soapbox/locales/messages.ts b/app/soapbox/locales/messages.ts index d1e3550124..1f69648e03 100644 --- a/app/soapbox/locales/messages.ts +++ b/app/soapbox/locales/messages.ts @@ -26,7 +26,7 @@ const importMessagesWithCustom = (locale: string): Promise => { }); }; -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 Promise>); export default messages; +export { locales }; \ No newline at end of file diff --git a/app/soapbox/schemas/soapbox/settings.ts b/app/soapbox/schemas/soapbox/settings.ts new file mode 100644 index 0000000000..1b0db4d863 --- /dev/null +++ b/app/soapbox/schemas/soapbox/settings.ts @@ -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; + +export { settingsSchema, type Settings }; \ No newline at end of file