diff --git a/frontend/app/components/global/WakelockSwitch.vue b/frontend/app/components/global/WakelockSwitch.vue index 721b43651..25801a94c 100644 --- a/frontend/app/components/global/WakelockSwitch.vue +++ b/frontend/app/components/global/WakelockSwitch.vue @@ -14,17 +14,25 @@ diff --git a/frontend/app/composables/use-users/preferences.ts b/frontend/app/composables/use-users/preferences.ts index 6bef65ebd..96869277f 100644 --- a/frontend/app/composables/use-users/preferences.ts +++ b/frontend/app/composables/use-users/preferences.ts @@ -73,6 +73,10 @@ export interface UserActivityPreferences { defaultActivity: ActivityKey; } +export interface UserExperiencePreferences { + lockScreen: boolean; +} + export function useUserMealPlanPreferences(): Ref { const fromStorage = useLocalStorage( "meal-planner-preferences", @@ -81,9 +85,7 @@ export function useUserMealPlanPreferences(): Ref { numberOfDays: 7, }, { mergeDefaults: true }, - // we cast to a Ref because by default it will return an optional type ref - // but since we pass defaults we know all properties are set. - ) as unknown as Ref; + ); return fromStorage; } @@ -92,15 +94,14 @@ export function useUserPrintPreferences(): Ref { const fromStorage = useLocalStorage( "recipe-print-preferences", { - imagePosition: "left", + imagePosition: "left" as ImagePosition, showDescription: true, showNotes: true, + showNutrition: false, expandChildRecipes: false, }, { mergeDefaults: true }, - // we cast to a Ref because by default it will return an optional type ref - // but since we pass defaults we know all properties are set. - ) as unknown as Ref; + ); return fromStorage; } @@ -118,9 +119,7 @@ export function useUserSortPreferences(): Ref { useMobileCards: false, }, { mergeDefaults: true }, - // we cast to a Ref because by default it will return an optional type ref - // but since we pass defaults we know all properties are set. - ) as unknown as Ref; + ); return fromStorage; } @@ -132,9 +131,7 @@ export function useUserActivityPreferences(): Ref { defaultActivity: ActivityKey.RECIPES, }, { mergeDefaults: true }, - // we cast to a Ref because by default it will return an optional type ref - // but since we pass defaults we know all properties are set. - ) as Ref; + ); return fromStorage; } @@ -146,9 +143,7 @@ export function useUserSearchQuerySession(): Ref { recipe: "", }, { mergeDefaults: true }, - // we cast to a Ref because by default it will return an optional type ref - // but since we pass defaults we know all properties are set. - ) as unknown as Ref; + ); return fromStorage; } @@ -160,9 +155,7 @@ export function useShoppingListPreferences(): Ref { viewAllLists: false, }, { mergeDefaults: true }, - // we cast to a Ref because by default it will return an optional type ref - // but since we pass defaults we know all properties are set. - ) as unknown as Ref; + ); return fromStorage; } @@ -175,9 +168,7 @@ export function useTimelinePreferences(): Ref { types: ["info", "system", "comment"] as TimelineEventType[], }, { mergeDefaults: true }, - // we cast to a Ref because by default it will return an optional type ref - // but since we pass defaults we know all properties are set. - ) as unknown as Ref; + ); return fromStorage; } @@ -186,12 +177,10 @@ export function useParsingPreferences(): Ref { const fromStorage = useLocalStorage( "parsing-preferences", { - parser: "nlp", + parser: "nlp" as RegisteredParser, }, { mergeDefaults: true }, - // we cast to a Ref because by default it will return an optional type ref - // but since we pass defaults we know all properties are set. - ) as unknown as Ref; + ); return fromStorage; } @@ -203,9 +192,7 @@ export function useCookbookPreferences(): Ref { hideOtherHouseholds: false, }, { mergeDefaults: true }, - // we cast to a Ref because by default it will return an optional type ref - // but since we pass defaults we know all properties are set. - ) as unknown as Ref; + ); return fromStorage; } @@ -224,9 +211,7 @@ export function useRecipeFinderPreferences(): Ref { includeToolsOnHand: true, }, { mergeDefaults: true }, - // we cast to a Ref because by default it will return an optional type ref - // but since we pass defaults we know all properties are set. - ) as unknown as Ref; + ); return fromStorage; } @@ -241,9 +226,19 @@ export function useRecipeCreatePreferences(): Ref { parseRecipe: true, }, { mergeDefaults: true }, - // we cast to a Ref because by default it will return an optional type ref - // but since we pass defaults we know all properties are set. - ) as unknown as Ref; + ); + + return fromStorage; +} + +export function useUserExperiencePreferences(): Ref { + const fromStorage = useLocalStorage( + "user-experience-preferences", + { + lockScreen: true, + }, + { mergeDefaults: true }, + ); return fromStorage; }