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/26412 - Remove try catch for NimbusFeatureException from FxNimbus value() getter
This commit is contained in:
parent
dcfcb4dcf5
commit
2e5537d9a5
@ -4,10 +4,8 @@
|
||||
|
||||
package org.mozilla.fenix.components.settings
|
||||
|
||||
import mozilla.components.support.base.log.logger.Logger
|
||||
import mozilla.components.support.ktx.android.content.PreferencesHolder
|
||||
import mozilla.components.support.ktx.android.content.booleanPreference
|
||||
import org.mozilla.experiments.nimbus.internal.NimbusFeatureException
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
@ -29,16 +27,8 @@ fun featureFlagPreference(key: String, default: Boolean, featureFlag: Boolean) =
|
||||
private class LazyPreference(val key: String, val default: () -> Boolean) :
|
||||
ReadWriteProperty<PreferencesHolder, Boolean> {
|
||||
|
||||
override fun getValue(thisRef: PreferencesHolder, property: KProperty<*>): Boolean {
|
||||
val defValue = try {
|
||||
default()
|
||||
} catch (e: NimbusFeatureException) {
|
||||
Logger.error("Failed fetch default value for $key", e)
|
||||
false
|
||||
}
|
||||
|
||||
return thisRef.preferences.getBoolean(key, defValue)
|
||||
}
|
||||
override fun getValue(thisRef: PreferencesHolder, property: KProperty<*>): Boolean =
|
||||
thisRef.preferences.getBoolean(key, default())
|
||||
|
||||
override fun setValue(thisRef: PreferencesHolder, property: KProperty<*>, value: Boolean) =
|
||||
thisRef.preferences.edit().putBoolean(key, value).apply()
|
||||
|
@ -28,7 +28,6 @@ import mozilla.components.support.ktx.android.content.longPreference
|
||||
import mozilla.components.support.ktx.android.content.stringPreference
|
||||
import mozilla.components.support.ktx.android.content.stringSetPreference
|
||||
import mozilla.components.support.locale.LocaleManager
|
||||
import org.mozilla.experiments.nimbus.internal.NimbusFeatureException
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.Config
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
@ -1204,11 +1203,8 @@ class Settings(private val appContext: Context) : PreferencesHolder {
|
||||
private val onboardScreenSection: Map<OnboardingSection, Boolean> get() =
|
||||
FxNimbus.features.onboarding.value().sectionsEnabled
|
||||
|
||||
private val homescreenSections: Map<HomeScreenSection, Boolean> get() = try {
|
||||
private val homescreenSections: Map<HomeScreenSection, Boolean> get() =
|
||||
FxNimbus.features.homescreen.value().sectionsEnabled
|
||||
} catch (e: NimbusFeatureException) {
|
||||
emptyMap()
|
||||
}
|
||||
|
||||
var historyMetadataUIFeature by lazyFeatureFlagPreference(
|
||||
appContext.getPreferenceKey(R.string.pref_key_history_metadata_feature),
|
||||
|
Loading…
Reference in New Issue
Block a user