-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into Jetpack-Focus-Disable-notifications-from-Je…
…tpack-app # Conflicts: # WordPress/src/test/java/org/wordpress/android/ui/main/jetpack/migration/JetpackMigrationViewModelTest.kt
- Loading branch information
Showing
28 changed files
with
319 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
WordPress/src/main/java/org/wordpress/android/localcontentmigration/MigrationEmailHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.wordpress.android.localcontentmigration | ||
|
||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Job | ||
import kotlinx.coroutines.launch | ||
import org.wordpress.android.fluxc.store.mobile.JetpackMigrationStore | ||
import org.wordpress.android.fluxc.store.mobile.MigrationCompleteFetchedPayload.Error | ||
import org.wordpress.android.fluxc.store.mobile.MigrationCompleteFetchedPayload.Success | ||
import org.wordpress.android.localcontentmigration.ContentMigrationAnalyticsTracker.ErrorType.EmailError | ||
import org.wordpress.android.modules.BG_THREAD | ||
import javax.inject.Inject | ||
import javax.inject.Named | ||
import kotlin.coroutines.CoroutineContext | ||
|
||
class MigrationEmailHelper @Inject constructor( | ||
private val jetpackMigrationStore: JetpackMigrationStore, | ||
private val migrationAnalyticsTracker: ContentMigrationAnalyticsTracker, | ||
@Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher, | ||
) : CoroutineScope { | ||
private val job = Job() | ||
override val coroutineContext: CoroutineContext | ||
get() = bgDispatcher + job | ||
|
||
fun notifyMigrationComplete() = launch(bgDispatcher) { | ||
when (val result = jetpackMigrationStore.migrationComplete()) { | ||
is Success -> migrationAnalyticsTracker.trackMigrationEmailSuccess() | ||
is Error -> migrationAnalyticsTracker.trackMigrationEmailFailed(EmailError(result.error?.message)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.