mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-19 12:18:59 +00:00
fix Issue when changing push notification preferences. Fixes #1127
This commit is contained in:
parent
51837cdf6b
commit
c439a07566
1 changed files with 9 additions and 0 deletions
|
|
@ -10,6 +10,9 @@ import io.reactivex.functions.Consumer
|
|||
|
||||
class PushNotificationsPreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
private var isInitialSet: Boolean = true
|
||||
private var isSettingUser: Boolean = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
HabiticaBaseApplication.component?.inject(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
@ -31,6 +34,7 @@ class PushNotificationsPreferencesFragment : BasePreferencesFragment(), SharedPr
|
|||
|
||||
override fun setUser(user: User?) {
|
||||
super.setUser(user)
|
||||
isSettingUser = !isInitialSet
|
||||
updatePreference("preference_push_you_won_challenge", user?.preferences?.pushNotifications?.wonChallenge)
|
||||
updatePreference("preference_push_received_a_private_message", user?.preferences?.pushNotifications?.newPM)
|
||||
updatePreference("preference_push_gifted_gems", user?.preferences?.pushNotifications?.giftedGems)
|
||||
|
|
@ -40,6 +44,8 @@ class PushNotificationsPreferencesFragment : BasePreferencesFragment(), SharedPr
|
|||
updatePreference("preference_push_your_quest_has_begun", user?.preferences?.pushNotifications?.questStarted)
|
||||
updatePreference("preference_push_invited_to_quest", user?.preferences?.pushNotifications?.invitedQuest)
|
||||
updatePreference("preference_push_important_announcements", user?.preferences?.pushNotifications?.majorUpdates)
|
||||
isSettingUser = false
|
||||
isInitialSet = false
|
||||
}
|
||||
|
||||
private fun updatePreference(key: String, isChecked: Boolean?) {
|
||||
|
|
@ -48,6 +54,9 @@ class PushNotificationsPreferencesFragment : BasePreferencesFragment(), SharedPr
|
|||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
if (isSettingUser) {
|
||||
return
|
||||
}
|
||||
val pathKey = when (key) {
|
||||
"preference_push_you_won_challenge" -> "wonChallenge"
|
||||
"preference_push_received_a_private_message" -> "newPM"
|
||||
|
|
|
|||
Loading…
Reference in a new issue