Skip to content

Commit 9f83c22

Browse files
authored
Merge pull request #1715 from Infomaniak/remove-duplicate
Remove duplicated Draft folder refresh
2 parents a848fa7 + cf94723 commit 9f83c22

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

app/src/main/java/com/infomaniak/mail/ui/MainActivity.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ class MainActivity : BaseActivity() {
330330
* We want to scheduleWork after a delay in the off chance where we came back from NewMessageActivity while an Activity
331331
* recreation got triggered.
332332
*
333-
* We need to give time to the NewMessageActivity to save the last state of the draft in realm and then scheduleWork on its
334-
* own. Not waiting would scheduleWork before NewMessageActivity has time to write to realm and schedule its own worker. This
335-
* would result in an attempt to save any temporary draft saved to realm because of saveDraftDebouncing() effectively sending
336-
* a second unwanted draft.
333+
* We need to give time to the NewMessageActivity to save the last state of the draft in Realm and then scheduleWork on its
334+
* own. Not waiting would scheduleWork before NewMessageActivity has time to write to Realm and schedule its own worker. This
335+
* would result in an attempt to save any temporary Draft saved to Realm because of saveDraftDebouncing() effectively sending
336+
* a second unwanted Draft.
337337
*/
338338
private fun scheduleDraftActionsWorkWithDelay() = lifecycleScope.launch(Dispatchers.IO) {
339339
delay(1_000L)

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

-20
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,8 @@ import com.infomaniak.mail.utils.RealmChangesBinding.Companion.bindResultsChange
7575
import com.infomaniak.mail.utils.UiUtils.formatUnreadCount
7676
import com.infomaniak.mail.utils.Utils.isPermanentDeleteFolder
7777
import com.infomaniak.mail.utils.Utils.runCatchingRealm
78-
import com.infomaniak.mail.utils.WorkerUtils
7978
import com.infomaniak.mail.utils.extensions.*
80-
import com.infomaniak.mail.workers.DraftsActionsWorker
8179
import dagger.hilt.android.AndroidEntryPoint
82-
import io.realm.kotlin.ext.isValid
8380
import io.sentry.Sentry
8481
import io.sentry.SentryLevel
8582
import java.util.Date
@@ -107,9 +104,6 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
107104
@Inject
108105
lateinit var localSettings: LocalSettings
109106

110-
@Inject
111-
lateinit var draftsActionsWorkerScheduler: DraftsActionsWorker.Scheduler
112-
113107
@Inject
114108
lateinit var notificationManagerCompat: NotificationManagerCompat
115109

@@ -163,7 +157,6 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
163157
observeCurrentFolder()
164158
observeCurrentFolderLive()
165159
observeUpdatedAtTriggers()
166-
observerDraftsActionsCompletedWorks()
167160
observeFlushFolderTrigger()
168161
observeUpdateInstall()
169162
}.getOrDefault(Unit)
@@ -617,19 +610,6 @@ class ThreadListFragment : TwoPaneFragment(), SwipeRefreshLayout.OnRefreshListen
617610
threadListViewModel.updatedAtTrigger.observe(viewLifecycleOwner) { updateUpdatedAt() }
618611
}
619612

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-
633613
private fun observeFlushFolderTrigger() {
634614
mainViewModel.flushFolderTrigger.observe(viewLifecycleOwner) { descriptionDialog.resetLoadingAndDismiss() }
635615
}

0 commit comments

Comments
 (0)