Add simplified sliding sync toggle to developer options
This commit is contained in:
parent
f2378ca6ea
commit
34015b337e
13 changed files with 98 additions and 3 deletions
|
|
@ -21,5 +21,6 @@ import io.element.android.libraries.featureflag.ui.model.FeatureUiModel
|
||||||
sealed interface DeveloperSettingsEvents {
|
sealed interface DeveloperSettingsEvents {
|
||||||
data class UpdateEnabledFeature(val feature: FeatureUiModel, val isEnabled: Boolean) : DeveloperSettingsEvents
|
data class UpdateEnabledFeature(val feature: FeatureUiModel, val isEnabled: Boolean) : DeveloperSettingsEvents
|
||||||
data class SetCustomElementCallBaseUrl(val baseUrl: String?) : DeveloperSettingsEvents
|
data class SetCustomElementCallBaseUrl(val baseUrl: String?) : DeveloperSettingsEvents
|
||||||
|
data class SetSimplifiedSlidingSyncEnabled(val isEnabled: Boolean) : DeveloperSettingsEvents
|
||||||
data object ClearCache : DeveloperSettingsEvents
|
data object ClearCache : DeveloperSettingsEvents
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,9 @@ class DeveloperSettingsPresenter @Inject constructor(
|
||||||
val customElementCallBaseUrl by appPreferencesStore
|
val customElementCallBaseUrl by appPreferencesStore
|
||||||
.getCustomElementCallBaseUrlFlow()
|
.getCustomElementCallBaseUrlFlow()
|
||||||
.collectAsState(initial = null)
|
.collectAsState(initial = null)
|
||||||
|
val isSimplifiedSlidingSyncEnabled by appPreferencesStore
|
||||||
|
.isSimplifiedSlidingSyncEnabledFlow()
|
||||||
|
.collectAsState(initial = false)
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
FeatureFlags.entries
|
FeatureFlags.entries
|
||||||
|
|
@ -114,6 +117,9 @@ class DeveloperSettingsPresenter @Inject constructor(
|
||||||
appPreferencesStore.setCustomElementCallBaseUrl(urlToSave)
|
appPreferencesStore.setCustomElementCallBaseUrl(urlToSave)
|
||||||
}
|
}
|
||||||
DeveloperSettingsEvents.ClearCache -> coroutineScope.clearCache(clearCacheAction)
|
DeveloperSettingsEvents.ClearCache -> coroutineScope.clearCache(clearCacheAction)
|
||||||
|
is DeveloperSettingsEvents.SetSimplifiedSlidingSyncEnabled -> coroutineScope.launch {
|
||||||
|
appPreferencesStore.setSimplifiedSlidingSyncEnabled(event.isEnabled)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,6 +133,7 @@ class DeveloperSettingsPresenter @Inject constructor(
|
||||||
defaultUrl = ElementCallConfig.DEFAULT_BASE_URL,
|
defaultUrl = ElementCallConfig.DEFAULT_BASE_URL,
|
||||||
validator = ::customElementCallUrlValidator,
|
validator = ::customElementCallUrlValidator,
|
||||||
),
|
),
|
||||||
|
isSimpleSlidingSyncEnabled = isSimplifiedSlidingSyncEnabled,
|
||||||
eventSink = ::handleEvents
|
eventSink = ::handleEvents
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ data class DeveloperSettingsState(
|
||||||
val rageshakeState: RageshakePreferencesState,
|
val rageshakeState: RageshakePreferencesState,
|
||||||
val clearCacheAction: AsyncData<Unit>,
|
val clearCacheAction: AsyncData<Unit>,
|
||||||
val customElementCallBaseUrlState: CustomElementCallBaseUrlState,
|
val customElementCallBaseUrlState: CustomElementCallBaseUrlState,
|
||||||
|
val isSimpleSlidingSyncEnabled: Boolean,
|
||||||
val eventSink: (DeveloperSettingsEvents) -> Unit
|
val eventSink: (DeveloperSettingsEvents) -> Unit
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ open class DeveloperSettingsStateProvider : PreviewParameterProvider<DeveloperSe
|
||||||
fun aDeveloperSettingsState(
|
fun aDeveloperSettingsState(
|
||||||
clearCacheAction: AsyncData<Unit> = AsyncData.Uninitialized,
|
clearCacheAction: AsyncData<Unit> = AsyncData.Uninitialized,
|
||||||
customElementCallBaseUrlState: CustomElementCallBaseUrlState = aCustomElementCallBaseUrlState(),
|
customElementCallBaseUrlState: CustomElementCallBaseUrlState = aCustomElementCallBaseUrlState(),
|
||||||
|
isSimplifiedSlidingSyncEnabled: Boolean = false,
|
||||||
eventSink: (DeveloperSettingsEvents) -> Unit = {},
|
eventSink: (DeveloperSettingsEvents) -> Unit = {},
|
||||||
) = DeveloperSettingsState(
|
) = DeveloperSettingsState(
|
||||||
features = aFeatureUiModelList(),
|
features = aFeatureUiModelList(),
|
||||||
|
|
@ -46,6 +47,7 @@ fun aDeveloperSettingsState(
|
||||||
cacheSize = AsyncData.Success("1.2 MB"),
|
cacheSize = AsyncData.Success("1.2 MB"),
|
||||||
clearCacheAction = clearCacheAction,
|
clearCacheAction = clearCacheAction,
|
||||||
customElementCallBaseUrlState = customElementCallBaseUrlState,
|
customElementCallBaseUrlState = customElementCallBaseUrlState,
|
||||||
|
isSimpleSlidingSyncEnabled = isSimplifiedSlidingSyncEnabled,
|
||||||
eventSink = eventSink,
|
eventSink = eventSink,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import io.element.android.features.preferences.impl.R
|
||||||
import io.element.android.features.rageshake.api.preferences.RageshakePreferencesView
|
import io.element.android.features.rageshake.api.preferences.RageshakePreferencesView
|
||||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceCategory
|
import io.element.android.libraries.designsystem.components.preferences.PreferenceCategory
|
||||||
import io.element.android.libraries.designsystem.components.preferences.PreferencePage
|
import io.element.android.libraries.designsystem.components.preferences.PreferencePage
|
||||||
|
import io.element.android.libraries.designsystem.components.preferences.PreferenceSwitch
|
||||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceText
|
import io.element.android.libraries.designsystem.components.preferences.PreferenceText
|
||||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceTextField
|
import io.element.android.libraries.designsystem.components.preferences.PreferenceTextField
|
||||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
|
|
@ -60,6 +61,14 @@ fun DeveloperSettingsView(
|
||||||
title = "Configure tracing",
|
title = "Configure tracing",
|
||||||
onClick = onOpenConfigureTracing,
|
onClick = onOpenConfigureTracing,
|
||||||
)
|
)
|
||||||
|
PreferenceSwitch(
|
||||||
|
title = "Enable Simplified Sliding Sync",
|
||||||
|
subtitle = "This option requires an app restart to work.",
|
||||||
|
isChecked = state.isSimpleSlidingSyncEnabled,
|
||||||
|
onCheckedChange = {
|
||||||
|
state.eventSink(DeveloperSettingsEvents.SetSimplifiedSlidingSyncEnabled(it))
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
PreferenceCategory(title = "Showkase") {
|
PreferenceCategory(title = "Showkase") {
|
||||||
PreferenceText(
|
PreferenceText(
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||||
import io.element.android.libraries.preferences.test.InMemoryAppPreferencesStore
|
import io.element.android.libraries.preferences.test.InMemoryAppPreferencesStore
|
||||||
import io.element.android.tests.testutils.WarmUpRule
|
import io.element.android.tests.testutils.WarmUpRule
|
||||||
import io.element.android.tests.testutils.awaitLastSequentialItem
|
import io.element.android.tests.testutils.awaitLastSequentialItem
|
||||||
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
@ -55,6 +56,7 @@ class DeveloperSettingsPresenterTest {
|
||||||
assertThat(initialState.cacheSize).isEqualTo(AsyncData.Uninitialized)
|
assertThat(initialState.cacheSize).isEqualTo(AsyncData.Uninitialized)
|
||||||
assertThat(initialState.customElementCallBaseUrlState).isNotNull()
|
assertThat(initialState.customElementCallBaseUrlState).isNotNull()
|
||||||
assertThat(initialState.customElementCallBaseUrlState.baseUrl).isNull()
|
assertThat(initialState.customElementCallBaseUrlState.baseUrl).isNull()
|
||||||
|
assertThat(initialState.isSimpleSlidingSyncEnabled).isFalse()
|
||||||
val loadedState = awaitItem()
|
val loadedState = awaitItem()
|
||||||
assertThat(loadedState.rageshakeState.isEnabled).isFalse()
|
assertThat(loadedState.rageshakeState.isEnabled).isFalse()
|
||||||
assertThat(loadedState.rageshakeState.isSupported).isTrue()
|
assertThat(loadedState.rageshakeState.isSupported).isTrue()
|
||||||
|
|
@ -160,6 +162,26 @@ class DeveloperSettingsPresenterTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - toggling simplified sliding sync changes the preferences`() = runTest {
|
||||||
|
val preferences = InMemoryAppPreferencesStore()
|
||||||
|
val presenter = createDeveloperSettingsPresenter(preferencesStore = preferences)
|
||||||
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
|
presenter.present()
|
||||||
|
}.test {
|
||||||
|
val initialState = awaitLastSequentialItem()
|
||||||
|
assertThat(initialState.isSimpleSlidingSyncEnabled).isFalse()
|
||||||
|
|
||||||
|
initialState.eventSink(DeveloperSettingsEvents.SetSimplifiedSlidingSyncEnabled(true))
|
||||||
|
assertThat(awaitItem().isSimpleSlidingSyncEnabled).isTrue()
|
||||||
|
assertThat(preferences.isSimplifiedSlidingSyncEnabledFlow().first()).isTrue()
|
||||||
|
|
||||||
|
initialState.eventSink(DeveloperSettingsEvents.SetSimplifiedSlidingSyncEnabled(false))
|
||||||
|
assertThat(awaitItem().isSimpleSlidingSyncEnabled).isFalse()
|
||||||
|
assertThat(preferences.isSimplifiedSlidingSyncEnabledFlow().first()).isFalse()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun createDeveloperSettingsPresenter(
|
private fun createDeveloperSettingsPresenter(
|
||||||
featureFlagService: FakeFeatureFlagService = FakeFeatureFlagService(),
|
featureFlagService: FakeFeatureFlagService = FakeFeatureFlagService(),
|
||||||
cacheSizeUseCase: FakeComputeCacheSizeUseCase = FakeComputeCacheSizeUseCase(),
|
cacheSizeUseCase: FakeComputeCacheSizeUseCase = FakeComputeCacheSizeUseCase(),
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,19 @@ class DeveloperSettingsViewTest {
|
||||||
rule.onNodeWithText("Clear cache").performClick()
|
rule.onNodeWithText("Clear cache").performClick()
|
||||||
eventsRecorder.assertSingle(DeveloperSettingsEvents.ClearCache)
|
eventsRecorder.assertSingle(DeveloperSettingsEvents.ClearCache)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Config(qualifiers = "h1500dp")
|
||||||
|
@Test
|
||||||
|
fun `clicking on the simplified sliding sync switch emits the expected event`() {
|
||||||
|
val eventsRecorder = EventsRecorder<DeveloperSettingsEvents>()
|
||||||
|
rule.setDeveloperSettingsView(
|
||||||
|
state = aDeveloperSettingsState(
|
||||||
|
eventSink = eventsRecorder
|
||||||
|
),
|
||||||
|
)
|
||||||
|
rule.onNodeWithText("Enable Simplified Sliding Sync").performClick()
|
||||||
|
eventsRecorder.assertSingle(DeveloperSettingsEvents.SetSimplifiedSlidingSyncEnabled(true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setDeveloperSettingsView(
|
private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setDeveloperSettingsView(
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,13 @@ dependencies {
|
||||||
debugImplementation(libs.matrix.sdk)
|
debugImplementation(libs.matrix.sdk)
|
||||||
}
|
}
|
||||||
implementation(projects.appconfig)
|
implementation(projects.appconfig)
|
||||||
implementation(projects.libraries.di)
|
|
||||||
implementation(projects.libraries.androidutils)
|
implementation(projects.libraries.androidutils)
|
||||||
|
implementation(projects.libraries.di)
|
||||||
|
implementation(projects.libraries.featureflag.api)
|
||||||
implementation(projects.libraries.network)
|
implementation(projects.libraries.network)
|
||||||
|
implementation(projects.libraries.preferences.api)
|
||||||
implementation(projects.services.analytics.api)
|
implementation(projects.services.analytics.api)
|
||||||
implementation(projects.services.toolbox.api)
|
implementation(projects.services.toolbox.api)
|
||||||
implementation(projects.libraries.featureflag.api)
|
|
||||||
api(projects.libraries.matrix.api)
|
api(projects.libraries.matrix.api)
|
||||||
implementation(libs.dagger)
|
implementation(libs.dagger)
|
||||||
implementation(projects.libraries.core)
|
implementation(projects.libraries.core)
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ import io.element.android.libraries.matrix.impl.util.anonymizedTokens
|
||||||
import io.element.android.libraries.matrix.impl.util.cancelAndDestroy
|
import io.element.android.libraries.matrix.impl.util.cancelAndDestroy
|
||||||
import io.element.android.libraries.matrix.impl.util.mxCallbackFlow
|
import io.element.android.libraries.matrix.impl.util.mxCallbackFlow
|
||||||
import io.element.android.libraries.matrix.impl.verification.RustSessionVerificationService
|
import io.element.android.libraries.matrix.impl.verification.RustSessionVerificationService
|
||||||
|
import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
||||||
import io.element.android.libraries.sessionstorage.api.SessionStore
|
import io.element.android.libraries.sessionstorage.api.SessionStore
|
||||||
import io.element.android.services.toolbox.api.systemclock.SystemClock
|
import io.element.android.services.toolbox.api.systemclock.SystemClock
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
|
|
@ -126,6 +127,7 @@ class RustMatrixClient(
|
||||||
private val baseDirectory: File,
|
private val baseDirectory: File,
|
||||||
baseCacheDirectory: File,
|
baseCacheDirectory: File,
|
||||||
private val clock: SystemClock,
|
private val clock: SystemClock,
|
||||||
|
private val appPreferencesStore: AppPreferencesStore,
|
||||||
) : MatrixClient {
|
) : MatrixClient {
|
||||||
override val sessionId: UserId = UserId(client.userId())
|
override val sessionId: UserId = UserId(client.userId())
|
||||||
override val deviceId: String = client.deviceId()
|
override val deviceId: String = client.deviceId()
|
||||||
|
|
@ -554,6 +556,7 @@ class RustMatrixClient(
|
||||||
}
|
}
|
||||||
close()
|
close()
|
||||||
deleteSessionDirectory(deleteCryptoDb = true)
|
deleteSessionDirectory(deleteCryptoDb = true)
|
||||||
|
appPreferencesStore.setSimplifiedSlidingSyncEnabled(false)
|
||||||
if (removeSession) {
|
if (removeSession) {
|
||||||
sessionStore.removeSession(sessionId.value)
|
sessionStore.removeSession(sessionId.value)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,12 @@ import io.element.android.libraries.matrix.impl.certificates.UserCertificatesPro
|
||||||
import io.element.android.libraries.matrix.impl.proxy.ProxyProvider
|
import io.element.android.libraries.matrix.impl.proxy.ProxyProvider
|
||||||
import io.element.android.libraries.matrix.impl.util.anonymizedTokens
|
import io.element.android.libraries.matrix.impl.util.anonymizedTokens
|
||||||
import io.element.android.libraries.network.useragent.UserAgentProvider
|
import io.element.android.libraries.network.useragent.UserAgentProvider
|
||||||
|
import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
||||||
import io.element.android.libraries.sessionstorage.api.SessionData
|
import io.element.android.libraries.sessionstorage.api.SessionData
|
||||||
import io.element.android.libraries.sessionstorage.api.SessionStore
|
import io.element.android.libraries.sessionstorage.api.SessionStore
|
||||||
import io.element.android.services.toolbox.api.systemclock.SystemClock
|
import io.element.android.services.toolbox.api.systemclock.SystemClock
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.matrix.rustcomponents.sdk.ClientBuilder
|
import org.matrix.rustcomponents.sdk.ClientBuilder
|
||||||
import org.matrix.rustcomponents.sdk.Session
|
import org.matrix.rustcomponents.sdk.Session
|
||||||
|
|
@ -46,9 +48,14 @@ class RustMatrixClientFactory @Inject constructor(
|
||||||
private val proxyProvider: ProxyProvider,
|
private val proxyProvider: ProxyProvider,
|
||||||
private val clock: SystemClock,
|
private val clock: SystemClock,
|
||||||
private val utdTracker: UtdTracker,
|
private val utdTracker: UtdTracker,
|
||||||
|
private val appPreferencesStore: AppPreferencesStore,
|
||||||
) {
|
) {
|
||||||
suspend fun create(sessionData: SessionData): RustMatrixClient = withContext(coroutineDispatchers.io) {
|
suspend fun create(sessionData: SessionData): RustMatrixClient = withContext(coroutineDispatchers.io) {
|
||||||
val client = getBaseClientBuilder(sessionData.sessionPath, sessionData.passphrase)
|
val client = getBaseClientBuilder(
|
||||||
|
sessionPath = sessionData.sessionPath,
|
||||||
|
passphrase = sessionData.passphrase,
|
||||||
|
useSimplifiedSlidingSync = appPreferencesStore.isSimplifiedSlidingSyncEnabledFlow().first(),
|
||||||
|
)
|
||||||
.homeserverUrl(sessionData.homeserverUrl)
|
.homeserverUrl(sessionData.homeserverUrl)
|
||||||
.username(sessionData.userId)
|
.username(sessionData.userId)
|
||||||
.use { it.build() }
|
.use { it.build() }
|
||||||
|
|
@ -70,6 +77,7 @@ class RustMatrixClientFactory @Inject constructor(
|
||||||
baseDirectory = baseDirectory,
|
baseDirectory = baseDirectory,
|
||||||
baseCacheDirectory = cacheDirectory,
|
baseCacheDirectory = cacheDirectory,
|
||||||
clock = clock,
|
clock = clock,
|
||||||
|
appPreferencesStore = appPreferencesStore,
|
||||||
).also {
|
).also {
|
||||||
Timber.tag(it.toString()).d("Creating Client with access token '$anonymizedAccessToken' and refresh token '$anonymizedRefreshToken'")
|
Timber.tag(it.toString()).d("Creating Client with access token '$anonymizedAccessToken' and refresh token '$anonymizedRefreshToken'")
|
||||||
}
|
}
|
||||||
|
|
@ -79,6 +87,7 @@ class RustMatrixClientFactory @Inject constructor(
|
||||||
sessionPath: String,
|
sessionPath: String,
|
||||||
passphrase: String?,
|
passphrase: String?,
|
||||||
slidingSyncProxy: String? = null,
|
slidingSyncProxy: String? = null,
|
||||||
|
useSimplifiedSlidingSync: Boolean = false,
|
||||||
): ClientBuilder {
|
): ClientBuilder {
|
||||||
return ClientBuilder()
|
return ClientBuilder()
|
||||||
.sessionPath(sessionPath)
|
.sessionPath(sessionPath)
|
||||||
|
|
@ -88,6 +97,7 @@ class RustMatrixClientFactory @Inject constructor(
|
||||||
.addRootCertificates(userCertificatesProvider.provides())
|
.addRootCertificates(userCertificatesProvider.provides())
|
||||||
.autoEnableBackups(true)
|
.autoEnableBackups(true)
|
||||||
.autoEnableCrossSigning(true)
|
.autoEnableCrossSigning(true)
|
||||||
|
.simplifiedSlidingSync(useSimplifiedSlidingSync)
|
||||||
.run {
|
.run {
|
||||||
// Workaround for non-nullable proxy parameter in the SDK, since each call to the ClientBuilder returns a new reference we need to keep
|
// Workaround for non-nullable proxy parameter in the SDK, since each call to the ClientBuilder returns a new reference we need to keep
|
||||||
proxyProvider.provides()?.let { proxy(it) } ?: this
|
proxyProvider.provides()?.let { proxy(it) } ?: this
|
||||||
|
|
|
||||||
|
|
@ -28,5 +28,8 @@ interface AppPreferencesStore {
|
||||||
suspend fun setTheme(theme: String)
|
suspend fun setTheme(theme: String)
|
||||||
fun getThemeFlow(): Flow<String?>
|
fun getThemeFlow(): Flow<String?>
|
||||||
|
|
||||||
|
suspend fun setSimplifiedSlidingSyncEnabled(enabled: Boolean)
|
||||||
|
fun isSimplifiedSlidingSyncEnabledFlow(): Flow<Boolean>
|
||||||
|
|
||||||
suspend fun reset()
|
suspend fun reset()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(na
|
||||||
private val developerModeKey = booleanPreferencesKey("developerMode")
|
private val developerModeKey = booleanPreferencesKey("developerMode")
|
||||||
private val customElementCallBaseUrlKey = stringPreferencesKey("elementCallBaseUrl")
|
private val customElementCallBaseUrlKey = stringPreferencesKey("elementCallBaseUrl")
|
||||||
private val themeKey = stringPreferencesKey("theme")
|
private val themeKey = stringPreferencesKey("theme")
|
||||||
|
private val simplifiedSlidingSyncKey = booleanPreferencesKey("useSimplifiedSlidingSync")
|
||||||
|
|
||||||
@ContributesBinding(AppScope::class)
|
@ContributesBinding(AppScope::class)
|
||||||
class DefaultAppPreferencesStore @Inject constructor(
|
class DefaultAppPreferencesStore @Inject constructor(
|
||||||
|
|
@ -87,6 +88,18 @@ class DefaultAppPreferencesStore @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun setSimplifiedSlidingSyncEnabled(enabled: Boolean) {
|
||||||
|
store.edit { prefs ->
|
||||||
|
prefs[simplifiedSlidingSyncKey] = enabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isSimplifiedSlidingSyncEnabledFlow(): Flow<Boolean> {
|
||||||
|
return store.data.map { prefs ->
|
||||||
|
prefs[simplifiedSlidingSyncKey] ?: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun reset() {
|
override suspend fun reset() {
|
||||||
store.edit { it.clear() }
|
store.edit { it.clear() }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,12 @@ class InMemoryAppPreferencesStore(
|
||||||
isDeveloperModeEnabled: Boolean = false,
|
isDeveloperModeEnabled: Boolean = false,
|
||||||
customElementCallBaseUrl: String? = null,
|
customElementCallBaseUrl: String? = null,
|
||||||
theme: String? = null,
|
theme: String? = null,
|
||||||
|
simplifiedSlidingSyncEnabled: Boolean = false
|
||||||
) : AppPreferencesStore {
|
) : AppPreferencesStore {
|
||||||
private val isDeveloperModeEnabled = MutableStateFlow(isDeveloperModeEnabled)
|
private val isDeveloperModeEnabled = MutableStateFlow(isDeveloperModeEnabled)
|
||||||
private val customElementCallBaseUrl = MutableStateFlow(customElementCallBaseUrl)
|
private val customElementCallBaseUrl = MutableStateFlow(customElementCallBaseUrl)
|
||||||
private val theme = MutableStateFlow(theme)
|
private val theme = MutableStateFlow(theme)
|
||||||
|
private val simplifiedSlidingSyncEnabled = MutableStateFlow(simplifiedSlidingSyncEnabled)
|
||||||
|
|
||||||
override suspend fun setDeveloperModeEnabled(enabled: Boolean) {
|
override suspend fun setDeveloperModeEnabled(enabled: Boolean) {
|
||||||
isDeveloperModeEnabled.value = enabled
|
isDeveloperModeEnabled.value = enabled
|
||||||
|
|
@ -53,6 +55,14 @@ class InMemoryAppPreferencesStore(
|
||||||
return theme
|
return theme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun setSimplifiedSlidingSyncEnabled(enabled: Boolean) {
|
||||||
|
simplifiedSlidingSyncEnabled.value = enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isSimplifiedSlidingSyncEnabledFlow(): Flow<Boolean> {
|
||||||
|
return simplifiedSlidingSyncEnabled
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun reset() {
|
override suspend fun reset() {
|
||||||
// No op
|
// No op
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue