Skip to content

Commit a96df1e

Browse files
committed
Rx tidy
1 parent d09170e commit a96df1e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

app/src/main/java/com/duckduckgo/app/httpsupgrade/api/HttpsUpgradeDataDownloader.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import com.duckduckgo.app.statistics.pixels.Pixel.PixelParameter.FAILURE_COUNT
2929
import com.duckduckgo.app.statistics.pixels.Pixel.PixelParameter.TOTAL_COUNT
3030
import com.duckduckgo.app.statistics.store.StatisticsDataStore
3131
import io.reactivex.Completable
32-
import io.reactivex.Completable.fromAction
32+
import io.reactivex.Completable.*
3333
import timber.log.Timber
3434
import java.io.IOException
3535
import javax.inject.Inject
@@ -114,20 +114,21 @@ class HttpsUpgradeDataDownloader @Inject constructor(
114114
}
115115

116116
fun reportUpgradeStatistics(): Completable {
117-
return fromAction {
117+
return defer {
118118

119119
if (statisticsDataStore.httpsUpgradesTotal == 0) {
120-
return@fromAction
120+
return@defer complete()
121121
}
122122
val params = mapOf(
123123
TOTAL_COUNT to statisticsDataStore.httpsUpgradesTotal.toString(),
124124
FAILURE_COUNT to statisticsDataStore.httpsUpgradesFailures.toString()
125125
)
126126

127-
pixel.fireCompletable(Pixel.PixelName.HTTPS_UPGRADE_SITE_SUMMARY, params).blockingGet()
128-
Timber.v("Sent https statistics")
129-
statisticsDataStore.httpsUpgradesTotal = 0
130-
statisticsDataStore.httpsUpgradesFailures = 0
127+
pixel.fireCompletable(Pixel.PixelName.HTTPS_UPGRADE_SITE_SUMMARY, params).andThen {
128+
Timber.v("Sent https statistics")
129+
statisticsDataStore.httpsUpgradesTotal = 0
130+
statisticsDataStore.httpsUpgradesFailures = 0
131+
}
131132
}
132133
}
133134

0 commit comments

Comments
 (0)