-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Describe the Bug
UserPreferences.getBool() and UserPreferences.getNumber() in app/lib/methods/userPreferences.ts use the || operator to return null for missing keys. However, this causes stored false (boolean) and 0 (number) values to also be incorrectly returned as null, because false || null → null and 0 || null → null.
// Line 113 — getBool
return this.mmkv.getBoolean(key) || null; // false || null → null ❌
// Line 143 — getNumber
return this.mmkv.getNumber(key) || null; // 0 || null → null ❌
Steps to Reproduce
- Set any boolean preference to false (e.g., disable a notification toggle).
- Close and reopen the app (or trigger a code path that reads the preference via UserPreferences.getBool()).
- Observe that the preference is read back as null instead of false, reverting to its default value.
Expected Behavior
getBool():should return false when the stored value is false, and
getNumber(): should return 0 when the stored value is 0. Only genuinely missing keys should return null.
Actual Behavior
Both false and 0 are coerced to null by the || operator, effectively resetting user preferences to their defaults on every read.
Rocket.Chat Server Version
8.2.0
Rocket.Chat App Version
4.70.0.999999999
Device Name
All devices (platform-independent logic bug)
OS Version
Android 15
Additional Context
No response