fix: State of user preferences UI does not reflect defaults

This commit is contained in:
Tom Moor
2023-07-08 11:02:58 -04:00
parent a8674c7dda
commit 6bc1b789ee
2 changed files with 4 additions and 5 deletions

View File

@@ -29,8 +29,7 @@ const Theme: React.FC = ({ children }) => {
<TooltipStyles />
<GlobalStyles
useCursorPointer={auth.user?.getPreference(
UserPreference.UseCursorPointer,
true
UserPreference.UseCursorPointer
)}
/>
{children}

View File

@@ -1,6 +1,7 @@
import { subMinutes } from "date-fns";
import { computed, action, observable } from "mobx";
import { now } from "mobx-utils";
import { UserPreferenceDefaults } from "@shared/constants";
import {
NotificationEventDefaults,
NotificationEventType,
@@ -126,11 +127,10 @@ class User extends ParanoidModel {
* none is set.
*
* @param key The UserPreference key to retrieve
* @param fallback An optional fallback value, defaults to false.
* @returns The value
*/
getPreference(key: UserPreference, fallback = false): boolean {
return this.preferences?.[key] ?? fallback;
getPreference(key: UserPreference): boolean {
return this.preferences?.[key] ?? UserPreferenceDefaults[key] ?? false;
}
/**