Skip to content

Commit 69a2876

Browse files
Simplify error-prone usage of canRefreshThreads
1 parent b927006 commit 69a2876

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/src/main/java/com/infomaniak/mail/ui/main/folder/ThreadListFragment.kt

+6-2
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,20 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
234234
super.onResume()
235235
refreshThreadsIfNotificationsAreDisabled()
236236
updateSwipeActionsAccordingToSettings()
237-
canRefreshThreads = true
238237
}
239238

240239
private fun refreshThreadsIfNotificationsAreDisabled() = with(mainViewModel) {
240+
241+
if (canRefreshThreads) {
241242
val areGoogleServicesDisabled = !playServicesUtils.areGooglePlayServicesAvailable()
242243
val areAppNotifsDisabled = !notificationManagerCompat.areNotificationsEnabled()
243244
val areMailboxNotifsDisabled = currentMailbox.value?.notificationsIsDisabled(notificationManagerCompat) == true
244245
val shouldRefreshThreads = areGoogleServicesDisabled || areAppNotifsDisabled || areMailboxNotifsDisabled
245246

246-
if (shouldRefreshThreads && canRefreshThreads) forceRefreshThreads()
247+
if (shouldRefreshThreads) forceRefreshThreads()
248+
}
249+
250+
canRefreshThreads = true
247251
}
248252

249253
private fun updateSwipeActionsAccordingToSettings() = with(binding.threadsList) {

0 commit comments

Comments
 (0)