1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 04:49:21 +00:00

Fix issue

This commit is contained in:
Pierre HUBERT 2021-04-12 19:34:06 +02:00
parent 612fc7b0d9
commit db49b6fa6b
2 changed files with 8 additions and 27 deletions

View File

@ -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 {

View File

@ -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");
// 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");
if (status == PushNotificationsStatus.INDEPENDENT) {
// TODO : Invoke plugin to apply new WebSocket URL
}
await (await PreferencesHelper.getInstance()).setString(
PreferencesKeyList.PUSH_NOTIFICATIONS_STATUS, response["status"]);
}
/// Clear local push notifications status