mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 22:39:22 +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.ENABLE_DARK_THEME: "dark_theme",
|
||||||
PreferencesKeyList.FORCE_MOBILE_MODE: "force_mobile_mode",
|
PreferencesKeyList.FORCE_MOBILE_MODE: "force_mobile_mode",
|
||||||
PreferencesKeyList.SHOW_PERFORMANCE_OVERLAY: "perfs_overlay",
|
PreferencesKeyList.SHOW_PERFORMANCE_OVERLAY: "perfs_overlay",
|
||||||
|
PreferencesKeyList.PUSH_NOTIFICATIONS_STATUS: "push_notifications_status",
|
||||||
};
|
};
|
||||||
|
|
||||||
class PreferencesHelper {
|
class PreferencesHelper {
|
||||||
|
@ -30,38 +30,18 @@ class PushNotificationsHelper {
|
|||||||
///
|
///
|
||||||
/// Throws in case of failure
|
/// Throws in case of failure
|
||||||
static Future<void> refreshLocalStatus() async {
|
static Future<void> refreshLocalStatus() async {
|
||||||
final pref = await PreferencesHelper.getInstance();
|
|
||||||
|
|
||||||
final response = await APIRequest.withLogin("push_notifications/status")
|
final response = await APIRequest.withLogin("push_notifications/status")
|
||||||
.execWithThrowGetObject();
|
.execWithThrowGetObject();
|
||||||
|
|
||||||
switch (response["status"]) {
|
var status = _PushNotificationsAPIMap[response["status"]];
|
||||||
case "undefined":
|
if (status == null) status = PushNotificationsStatus.UNDEFINED;
|
||||||
await pref.removeKey(PreferencesKeyList.PUSH_NOTIFICATIONS_STATUS);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "disabled":
|
if (status == PushNotificationsStatus.INDEPENDENT) {
|
||||||
await pref.setString(
|
// TODO : Invoke plugin to apply new WebSocket URL
|
||||||
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");
|
|
||||||
// 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
|
/// Clear local push notifications status
|
||||||
|
Loading…
Reference in New Issue
Block a user