Treat null/undefined notification settings as "not set"

Otherwise we end up lying and saying notifications are disabled, despite the push rules saying otherwise.

Part 1 of the fix for:
* https://github.com/vector-im/riot-web/issues/5603
* https://github.com/vector-im/riot-web/issues/5606

Signed-off-by: Travis Ralston <travpc@gmail.com>
pull/21833/head
Travis Ralston 2017-11-15 22:08:13 -07:00
parent 10a1d9cb29
commit 5976fb2eed
1 changed files with 9 additions and 3 deletions

View File

@ -40,11 +40,17 @@ export default class DeviceSettingsHandler extends SettingsHandler {
// Special case notifications
if (settingName === "notificationsEnabled") {
return localStorage.getItem("notifications_enabled") === "true";
const value = localStorage.getItem("notifications_enabled");
if (typeof(value) === "string") return value === "true";
return null; // wrong type or otherwise not set
} else if (settingName === "notificationBodyEnabled") {
return localStorage.getItem("notifications_body_enabled") === "true";
const value = localStorage.getItem("notifications_body_enabled");
if (typeof(value) === "string") return value === "true";
return null; // wrong type or otherwise not set
} else if (settingName === "audioNotificationsEnabled") {
return localStorage.getItem("audio_notifications_enabled") === "true";
const value = localStorage.getItem("audio_notifications_enabled");
if (typeof(value) === "string") return value === "true";
return null; // wrong type or otherwise not set
}
return this._getSettings()[settingName];