2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/15644: change apply to with in GleanMetricsService.

While the callback receiver is identical in these two methods, they're
semantically different: apply is for initializing the receiver while with
is anything else benefiting from a new `this` receiver.

I didn't change the usage of apply that has a return statement because I
was afraid my change might change behavior.
This commit is contained in:
Michael Comella 2020-10-14 15:33:36 -07:00 committed by Michael Comella
parent 910b7f19aa
commit aa19f541b2

View File

@ -762,7 +762,7 @@ class GleanMetricsService(
internal fun setStartupMetrics() { internal fun setStartupMetrics() {
setPreferenceMetrics() setPreferenceMetrics()
Metrics.apply { with(Metrics) {
defaultBrowser.set(browsersCache.all(context).isDefaultBrowser) defaultBrowser.set(browsersCache.all(context).isDefaultBrowser)
mozillaProductDetector.getMozillaBrowserDefault(context)?.also { mozillaProductDetector.getMozillaBrowserDefault(context)?.also {
defaultMozBrowser.set(it) defaultMozBrowser.set(it)
@ -819,7 +819,7 @@ class GleanMetricsService(
// We purposefully make all of our preferences the string_list format to make data analysis // We purposefully make all of our preferences the string_list format to make data analysis
// simpler. While it makes things like booleans a bit more complicated, it means all our // simpler. While it makes things like booleans a bit more complicated, it means all our
// preferences can be analyzed with the same dashboard and compared. // preferences can be analyzed with the same dashboard and compared.
Preferences.apply { with(Preferences) {
showSearchSuggestions.set(context.settings().shouldShowSearchSuggestions.toStringList()) showSearchSuggestions.set(context.settings().shouldShowSearchSuggestions.toStringList())
remoteDebugging.set(context.settings().isRemoteDebuggingEnabled.toStringList()) remoteDebugging.set(context.settings().isRemoteDebuggingEnabled.toStringList())
telemetry.set(context.settings().isTelemetryEnabled.toStringList()) telemetry.set(context.settings().isTelemetryEnabled.toStringList())