From 620bc2285ca488d40225409a28a74b525358ede4 Mon Sep 17 00:00:00 2001 From: Grishka Date: Thu, 28 Apr 2022 23:32:43 +0300 Subject: [PATCH] Fix notification settings getting reset on app update --- .../joinmastodon/android/api/PushSubscriptionManager.java | 6 +----- .../android/api/session/AccountSessionManager.java | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/PushSubscriptionManager.java b/mastodon/src/main/java/org/joinmastodon/android/api/PushSubscriptionManager.java index f20be90b..19f9e39b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/PushSubscriptionManager.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/PushSubscriptionManager.java @@ -121,10 +121,6 @@ public class PushSubscriptionManager{ return !TextUtils.isEmpty(deviceToken); } - public void registerAccountForPush(){ - registerAccountForPush(null); - } - public void registerAccountForPush(PushSubscription subscription){ if(TextUtils.isEmpty(deviceToken)) throw new IllegalStateException("No device push token available"); @@ -367,7 +363,7 @@ public class PushSubscriptionManager{ private static void registerAllAccountsForPush(boolean forceReRegister){ for(AccountSession session:AccountSessionManager.getInstance().getLoggedInAccounts()){ if(session.pushSubscription==null || forceReRegister) - session.getPushSubscriptionManager().registerAccountForPush(); + session.getPushSubscriptionManager().registerAccountForPush(session.pushSubscription); else if(session.needUpdatePushSettings) session.getPushSubscriptionManager().updatePushSettings(session.pushSubscription); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java index fb136385..f3a05f9f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSessionManager.java @@ -100,7 +100,7 @@ public class AccountSessionManager{ writeAccountsFile(); updateInstanceEmojis(instance, instance.uri); if(PushSubscriptionManager.arePushNotificationsAvailable()){ - session.getPushSubscriptionManager().registerAccountForPush(); + session.getPushSubscriptionManager().registerAccountForPush(null); } }