@@ -75,11 +75,8 @@ import com.infomaniak.mail.utils.RealmChangesBinding.Companion.bindResultsChange
75
75
import com.infomaniak.mail.utils.UiUtils.formatUnreadCount
76
76
import com.infomaniak.mail.utils.Utils.isPermanentDeleteFolder
77
77
import com.infomaniak.mail.utils.Utils.runCatchingRealm
78
- import com.infomaniak.mail.utils.WorkerUtils
79
78
import com.infomaniak.mail.utils.extensions.*
80
- import com.infomaniak.mail.workers.DraftsActionsWorker
81
79
import dagger.hilt.android.AndroidEntryPoint
82
- import io.realm.kotlin.ext.isValid
83
80
import io.sentry.Sentry
84
81
import io.sentry.SentryLevel
85
82
import java.util.Date
@@ -107,9 +104,6 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
107
104
@Inject
108
105
lateinit var localSettings: LocalSettings
109
106
110
- @Inject
111
- lateinit var draftsActionsWorkerScheduler: DraftsActionsWorker .Scheduler
112
-
113
107
@Inject
114
108
lateinit var notificationManagerCompat: NotificationManagerCompat
115
109
@@ -163,7 +157,6 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
163
157
observeCurrentFolder()
164
158
observeCurrentFolderLive()
165
159
observeUpdatedAtTriggers()
166
- observerDraftsActionsCompletedWorks()
167
160
observeFlushFolderTrigger()
168
161
observeUpdateInstall()
169
162
}.getOrDefault(Unit )
@@ -239,10 +232,10 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
239
232
private fun refreshThreadsIfNotificationsAreDisabled () = with (mainViewModel) {
240
233
241
234
if (canRefreshThreads) {
242
- val areGoogleServicesDisabled = ! playServicesUtils.areGooglePlayServicesAvailable()
243
- val areAppNotifsDisabled = ! notificationManagerCompat.areNotificationsEnabled()
244
- val areMailboxNotifsDisabled = currentMailbox.value?.notificationsIsDisabled(notificationManagerCompat) == true
245
- val shouldRefreshThreads = areGoogleServicesDisabled || areAppNotifsDisabled || areMailboxNotifsDisabled
235
+ val areGoogleServicesDisabled = ! playServicesUtils.areGooglePlayServicesAvailable()
236
+ val areAppNotifsDisabled = ! notificationManagerCompat.areNotificationsEnabled()
237
+ val areMailboxNotifsDisabled = currentMailbox.value?.notificationsIsDisabled(notificationManagerCompat) == true
238
+ val shouldRefreshThreads = areGoogleServicesDisabled || areAppNotifsDisabled || areMailboxNotifsDisabled
246
239
247
240
if (shouldRefreshThreads) forceRefreshThreads()
248
241
}
@@ -617,19 +610,6 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
617
610
threadListViewModel.updatedAtTrigger.observe(viewLifecycleOwner) { updateUpdatedAt() }
618
611
}
619
612
620
- private fun observerDraftsActionsCompletedWorks () {
621
-
622
- fun observeDraftsActions () {
623
- draftsActionsWorkerScheduler.getCompletedWorkInfoLiveData().observe(viewLifecycleOwner) {
624
- mainViewModel.currentFolder.value?.let { folder ->
625
- if (folder.isValid() && folder.role == FolderRole .DRAFT ) mainViewModel.forceRefreshThreads()
626
- }
627
- }
628
- }
629
-
630
- WorkerUtils .flushWorkersBefore(requireContext(), viewLifecycleOwner, ::observeDraftsActions)
631
- }
632
-
633
613
private fun observeFlushFolderTrigger () {
634
614
mainViewModel.flushFolderTrigger.observe(viewLifecycleOwner) { descriptionDialog.resetLoadingAndDismiss() }
635
615
}
0 commit comments