mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Fix issue
This commit is contained in:
		@@ -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");
 | 
			
		||||
        // 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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user