mirror of https://github.com/readrops/Readrops.git
Fix synchronization between feeds notifications permissions switches and enables all feeds notifications switch
This commit is contained in:
parent
6d0ebf063b
commit
4aa7ae7e4c
|
@ -34,6 +34,7 @@ class NotificationPermissionActivity : AppCompatActivity() {
|
||||||
val accountId = intent.getIntExtra(ACCOUNT_ID, 0)
|
val accountId = intent.getIntExtra(ACCOUNT_ID, 0)
|
||||||
val viewModel by viewModels<NotificationPermissionViewModel>()
|
val viewModel by viewModels<NotificationPermissionViewModel>()
|
||||||
var adapter: NotificationPermissionListAdapter? = null
|
var adapter: NotificationPermissionListAdapter? = null
|
||||||
|
var feedStateChanged = false
|
||||||
|
|
||||||
viewModel.getAccount(accountId).observe(this, Observer { account ->
|
viewModel.getAccount(accountId).observe(this, Observer { account ->
|
||||||
viewModel.account = account
|
viewModel.account = account
|
||||||
|
@ -59,6 +60,7 @@ class NotificationPermissionActivity : AppCompatActivity() {
|
||||||
|
|
||||||
binding.notifPermissionFeedsSwitch.isEnabled = account.isNotificationsEnabled
|
binding.notifPermissionFeedsSwitch.isEnabled = account.isNotificationsEnabled
|
||||||
binding.notifPermissionFeedsSwitch.setOnCheckedChangeListener { _, isChecked ->
|
binding.notifPermissionFeedsSwitch.setOnCheckedChangeListener { _, isChecked ->
|
||||||
|
if (!feedStateChanged) {
|
||||||
viewModel.setAllFeedsNotificationState(isChecked)
|
viewModel.setAllFeedsNotificationState(isChecked)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
@ -66,7 +68,12 @@ class NotificationPermissionActivity : AppCompatActivity() {
|
||||||
.subscribe()
|
.subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
feedStateChanged = false
|
||||||
|
}
|
||||||
|
|
||||||
adapter = NotificationPermissionListAdapter(account.isNotificationsEnabled) { feed ->
|
adapter = NotificationPermissionListAdapter(account.isNotificationsEnabled) { feed ->
|
||||||
|
feedStateChanged = true
|
||||||
|
|
||||||
viewModel.setFeedNotificationState(feed)
|
viewModel.setFeedNotificationState(feed)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
|
Loading…
Reference in New Issue