forked from github/wulkanowy-mirror
Fix NPE in SyncPresenter (#1582)
This commit is contained in:
parent
e3122127c0
commit
ac86737050
@ -74,7 +74,7 @@ class SyncManager @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startOneTimeSyncWorker(): Flow<WorkInfo> {
|
fun startOneTimeSyncWorker(): Flow<WorkInfo?> {
|
||||||
val work = OneTimeWorkRequestBuilder<SyncWorker>()
|
val work = OneTimeWorkRequestBuilder<SyncWorker>()
|
||||||
.setInputData(
|
.setInputData(
|
||||||
Data.Builder()
|
Data.Builder()
|
||||||
|
@ -46,7 +46,7 @@ class SyncPresenter @Inject constructor(
|
|||||||
fun onSyncNowClicked() {
|
fun onSyncNowClicked() {
|
||||||
view?.run {
|
view?.run {
|
||||||
syncManager.startOneTimeSyncWorker().onEach { workInfo ->
|
syncManager.startOneTimeSyncWorker().onEach { workInfo ->
|
||||||
when (workInfo.state) {
|
when (workInfo?.state) {
|
||||||
WorkInfo.State.ENQUEUED -> {
|
WorkInfo.State.ENQUEUED -> {
|
||||||
setSyncInProgress(true)
|
setSyncInProgress(true)
|
||||||
Timber.i("Setting sync now started")
|
Timber.i("Setting sync now started")
|
||||||
@ -63,9 +63,9 @@ class SyncPresenter @Inject constructor(
|
|||||||
)
|
)
|
||||||
analytics.logEvent("sync_now", "status" to "failed")
|
analytics.logEvent("sync_now", "status" to "failed")
|
||||||
}
|
}
|
||||||
else -> Timber.d("Sync now state: ${workInfo.state}")
|
else -> Timber.d("Sync now state: ${workInfo?.state}")
|
||||||
}
|
}
|
||||||
if (workInfo.state.isFinished) {
|
if (workInfo?.state?.isFinished == true) {
|
||||||
setSyncInProgress(false)
|
setSyncInProgress(false)
|
||||||
setSyncDateInView()
|
setSyncDateInView()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user