mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 04:49:21 +00:00
Fix issue
This commit is contained in:
parent
612fc7b0d9
commit
db49b6fa6b
@ -22,6 +22,7 @@ const _PreferenceKeysName = {
|
||||
PreferencesKeyList.ENABLE_DARK_THEME: "dark_theme",
|
||||
PreferencesKeyList.FORCE_MOBILE_MODE: "force_mobile_mode",
|
||||
PreferencesKeyList.SHOW_PERFORMANCE_OVERLAY: "perfs_overlay",
|
||||
PreferencesKeyList.PUSH_NOTIFICATIONS_STATUS: "push_notifications_status",
|
||||
};
|
||||
|
||||
class PreferencesHelper {
|
||||
|
@ -30,38 +30,18 @@ class PushNotificationsHelper {
|
||||
///
|
||||
/// Throws in case of failure
|
||||
static Future<void> refreshLocalStatus() async {
|
||||
final pref = await PreferencesHelper.getInstance();
|
||||
|
||||
final response = await APIRequest.withLogin("push_notifications/status")
|
||||
.execWithThrowGetObject();
|
||||
|
||||
switch (response["status"]) {
|
||||
case "undefined":
|
||||
await pref.removeKey(PreferencesKeyList.PUSH_NOTIFICATIONS_STATUS);
|
||||
break;
|
||||
var status = _PushNotificationsAPIMap[response["status"]];
|
||||
if (status == null) status = PushNotificationsStatus.UNDEFINED;
|
||||
|
||||
case "disabled":
|
||||
await pref.setString(
|
||||
PreferencesKeyList.PUSH_NOTIFICATIONS_STATUS, "disabled");
|
||||
break;
|
||||
|
||||
case "firebase":
|
||||
await pref.setString(
|
||||
PreferencesKeyList.PUSH_NOTIFICATIONS_STATUS, "firebase");
|
||||
break;
|
||||
|
||||
case "independent":
|
||||
await pref.setString(
|
||||
PreferencesKeyList.PUSH_NOTIFICATIONS_STATUS, "independent");
|
||||
if (status == PushNotificationsStatus.INDEPENDENT) {
|
||||
// TODO : Invoke plugin to apply new WebSocket URL
|
||||
break;
|
||||
|
||||
default:
|
||||
print(
|
||||
"Push notifications status ${response["status"]} is unknown, defaulting to disabled!");
|
||||
await pref.setString(
|
||||
PreferencesKeyList.PUSH_NOTIFICATIONS_STATUS, "disabled");
|
||||
}
|
||||
|
||||
await (await PreferencesHelper.getInstance()).setString(
|
||||
PreferencesKeyList.PUSH_NOTIFICATIONS_STATUS, response["status"]);
|
||||
}
|
||||
|
||||
/// Clear local push notifications status
|
||||
|
Loading…
Reference in New Issue
Block a user