Remove supportSlidingSync boolean.
Note that this field was not used (read) anymore, so this is just cleaning up the code.
This commit is contained in:
parent
40d1d768dd
commit
b6b59562c7
11 changed files with 7 additions and 85 deletions
|
|
@ -14,5 +14,4 @@ data class AccountProvider(
|
||||||
val isPublic: Boolean = false,
|
val isPublic: Boolean = false,
|
||||||
val isMatrixOrg: Boolean = false,
|
val isMatrixOrg: Boolean = false,
|
||||||
val isValid: Boolean = false,
|
val isValid: Boolean = false,
|
||||||
val supportSlidingSync: Boolean = false,
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,7 @@ open class AccountProviderProvider : PreviewParameterProvider<AccountProvider> {
|
||||||
get() = sequenceOf(
|
get() = sequenceOf(
|
||||||
anAccountProvider(),
|
anAccountProvider(),
|
||||||
anAccountProvider().copy(subtitle = null),
|
anAccountProvider().copy(subtitle = null),
|
||||||
anAccountProvider().copy(subtitle = null, title = "no.sliding.sync", supportSlidingSync = false),
|
anAccountProvider().copy(subtitle = null, title = "invalid", isValid = false),
|
||||||
anAccountProvider().copy(subtitle = null, title = "invalid", isValid = false, supportSlidingSync = false),
|
|
||||||
anAccountProvider().copy(subtitle = null, title = "Other", isPublic = false, isMatrixOrg = false),
|
anAccountProvider().copy(subtitle = null, title = "Other", isPublic = false, isMatrixOrg = false),
|
||||||
// Add other state here
|
// Add other state here
|
||||||
)
|
)
|
||||||
|
|
@ -28,5 +27,4 @@ fun anAccountProvider() = AccountProvider(
|
||||||
isPublic = true,
|
isPublic = true,
|
||||||
isMatrixOrg = true,
|
isMatrixOrg = true,
|
||||||
isValid = true,
|
isValid = true,
|
||||||
supportSlidingSync = true,
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,4 @@ data class HomeserverData(
|
||||||
val homeserverUrl: String,
|
val homeserverUrl: String,
|
||||||
// True if a wellknown file has been found and is valid. If false, it means that the [homeserverUrl] is valid
|
// True if a wellknown file has been found and is valid. If false, it means that the [homeserverUrl] is valid
|
||||||
val isWellknownValid: Boolean,
|
val isWellknownValid: Boolean,
|
||||||
// True if a wellknown file has been found and is valid and is claiming a sliding sync Url
|
|
||||||
val supportSlidingSync: Boolean,
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class HomeserverResolver @Inject constructor(
|
||||||
private val dispatchers: CoroutineDispatchers,
|
private val dispatchers: CoroutineDispatchers,
|
||||||
private val wellknownRequest: WellknownRequest,
|
private val wellknownRequest: WellknownRequest,
|
||||||
) {
|
) {
|
||||||
suspend fun resolve(userInput: String): Flow<List<HomeserverData>> = flow {
|
fun resolve(userInput: String): Flow<List<HomeserverData>> = flow {
|
||||||
val flowContext = currentCoroutineContext()
|
val flowContext = currentCoroutineContext()
|
||||||
val trimmedUserInput = userInput.trim()
|
val trimmedUserInput = userInput.trim()
|
||||||
if (trimmedUserInput.length < 4) return@flow
|
if (trimmedUserInput.length < 4) return@flow
|
||||||
|
|
@ -46,13 +46,11 @@ class HomeserverResolver @Inject constructor(
|
||||||
}
|
}
|
||||||
val isValid = wellKnown?.isValid().orFalse()
|
val isValid = wellKnown?.isValid().orFalse()
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
val supportSlidingSync = wellKnown?.supportSlidingSync().orFalse()
|
|
||||||
// Emit the list as soon as possible
|
// Emit the list as soon as possible
|
||||||
currentList.add(
|
currentList.add(
|
||||||
HomeserverData(
|
HomeserverData(
|
||||||
homeserverUrl = url,
|
homeserverUrl = url,
|
||||||
isWellknownValid = true,
|
isWellknownValid = true,
|
||||||
supportSlidingSync = supportSlidingSync
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
withContext(flowContext) {
|
withContext(flowContext) {
|
||||||
|
|
@ -68,7 +66,6 @@ class HomeserverResolver @Inject constructor(
|
||||||
HomeserverData(
|
HomeserverData(
|
||||||
homeserverUrl = trimmedUserInput,
|
homeserverUrl = trimmedUserInput,
|
||||||
isWellknownValid = false,
|
isWellknownValid = false,
|
||||||
supportSlidingSync = false,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,6 @@ import kotlinx.serialization.Serializable
|
||||||
* "m.identity_server": {
|
* "m.identity_server": {
|
||||||
* "base_url": "https://vector.im"
|
* "base_url": "https://vector.im"
|
||||||
* },
|
* },
|
||||||
* "org.matrix.msc3575.proxy": {
|
|
||||||
* "url": "https://slidingsync.lab.matrix.org"
|
|
||||||
* }
|
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
* .
|
* .
|
||||||
|
|
@ -34,14 +31,8 @@ data class WellKnown(
|
||||||
val homeServer: WellKnownBaseConfig? = null,
|
val homeServer: WellKnownBaseConfig? = null,
|
||||||
@SerialName("m.identity_server")
|
@SerialName("m.identity_server")
|
||||||
val identityServer: WellKnownBaseConfig? = null,
|
val identityServer: WellKnownBaseConfig? = null,
|
||||||
@SerialName("org.matrix.msc3575.proxy")
|
|
||||||
val slidingSyncProxy: WellKnownSlidingSyncConfig? = null,
|
|
||||||
) {
|
) {
|
||||||
fun isValid(): Boolean {
|
fun isValid(): Boolean {
|
||||||
return homeServer?.baseURL?.isNotBlank().orFalse()
|
return homeServer?.baseURL?.isNotBlank().orFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun supportSlidingSync(): Boolean {
|
|
||||||
return slidingSyncProxy?.url?.isNotBlank().orFalse()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2023, 2024 New Vector Ltd.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
* Please see LICENSE in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.element.android.features.login.impl.resolver.network
|
|
||||||
|
|
||||||
import kotlinx.serialization.SerialName
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class WellKnownSlidingSyncConfig(
|
|
||||||
@SerialName("url")
|
|
||||||
val url: String? = null,
|
|
||||||
)
|
|
||||||
|
|
@ -29,7 +29,6 @@ class ChangeAccountProviderPresenter @Inject constructor(
|
||||||
isPublic = true,
|
isPublic = true,
|
||||||
isMatrixOrg = true,
|
isMatrixOrg = true,
|
||||||
isValid = true,
|
isValid = true,
|
||||||
supportSlidingSync = true,
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
changeServerState = changeServerState,
|
changeServerState = changeServerState,
|
||||||
|
|
|
||||||
|
|
@ -34,20 +34,18 @@ fun aSearchAccountProviderState(
|
||||||
|
|
||||||
fun aHomeserverDataList(): List<HomeserverData> {
|
fun aHomeserverDataList(): List<HomeserverData> {
|
||||||
return listOf(
|
return listOf(
|
||||||
aHomeserverData(isWellknownValid = true, supportSlidingSync = true),
|
aHomeserverData(isWellknownValid = true),
|
||||||
aHomeserverData(homeserverUrl = "https://no.sliding.sync", isWellknownValid = true, supportSlidingSync = false),
|
aHomeserverData(homeserverUrl = "https://no.sliding.sync", isWellknownValid = true),
|
||||||
aHomeserverData(homeserverUrl = "https://invalid", isWellknownValid = false, supportSlidingSync = false),
|
aHomeserverData(homeserverUrl = "https://invalid", isWellknownValid = false),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun aHomeserverData(
|
fun aHomeserverData(
|
||||||
homeserverUrl: String = AuthenticationConfig.MATRIX_ORG_URL,
|
homeserverUrl: String = AuthenticationConfig.MATRIX_ORG_URL,
|
||||||
isWellknownValid: Boolean = true,
|
isWellknownValid: Boolean = true,
|
||||||
supportSlidingSync: Boolean = true,
|
|
||||||
): HomeserverData {
|
): HomeserverData {
|
||||||
return HomeserverData(
|
return HomeserverData(
|
||||||
homeserverUrl = homeserverUrl,
|
homeserverUrl = homeserverUrl,
|
||||||
isWellknownValid = isWellknownValid,
|
isWellknownValid = isWellknownValid,
|
||||||
supportSlidingSync = supportSlidingSync,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,6 @@ private fun HomeserverData.toAccountProvider(): AccountProvider {
|
||||||
isPublic = isMatrixOrg,
|
isPublic = isMatrixOrg,
|
||||||
isMatrixOrg = isMatrixOrg,
|
isMatrixOrg = isMatrixOrg,
|
||||||
isValid = isWellknownValid,
|
isValid = isWellknownValid,
|
||||||
supportSlidingSync = supportSlidingSync,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ class ChangeAccountProviderPresenterTest {
|
||||||
isPublic = true,
|
isPublic = true,
|
||||||
isMatrixOrg = true,
|
isMatrixOrg = true,
|
||||||
isValid = true,
|
isValid = true,
|
||||||
supportSlidingSync = true,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ import io.element.android.features.login.impl.resolver.HomeserverResolver
|
||||||
import io.element.android.features.login.impl.resolver.network.FakeWellknownRequest
|
import io.element.android.features.login.impl.resolver.network.FakeWellknownRequest
|
||||||
import io.element.android.features.login.impl.resolver.network.WellKnown
|
import io.element.android.features.login.impl.resolver.network.WellKnown
|
||||||
import io.element.android.features.login.impl.resolver.network.WellKnownBaseConfig
|
import io.element.android.features.login.impl.resolver.network.WellKnownBaseConfig
|
||||||
import io.element.android.features.login.impl.resolver.network.WellKnownSlidingSyncConfig
|
|
||||||
import io.element.android.libraries.architecture.AsyncData
|
import io.element.android.libraries.architecture.AsyncData
|
||||||
import io.element.android.libraries.matrix.test.A_HOMESERVER_URL
|
import io.element.android.libraries.matrix.test.A_HOMESERVER_URL
|
||||||
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
|
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
|
||||||
|
|
@ -98,7 +97,7 @@ class SearchAccountProviderPresenterTest {
|
||||||
assertThat(awaitItem().userInputResult).isEqualTo(
|
assertThat(awaitItem().userInputResult).isEqualTo(
|
||||||
AsyncData.Success(
|
AsyncData.Success(
|
||||||
listOf(
|
listOf(
|
||||||
aHomeserverData(homeserverUrl = "https://test.org", isWellknownValid = false, supportSlidingSync = false)
|
aHomeserverData(homeserverUrl = "https://test.org", isWellknownValid = false)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -106,42 +105,7 @@ class SearchAccountProviderPresenterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - enter text one result no sliding sync`() = runTest {
|
fun `present - enter text one result with wellknown`() = runTest {
|
||||||
val fakeWellknownRequest = FakeWellknownRequest()
|
|
||||||
fakeWellknownRequest.givenResultMap(
|
|
||||||
mapOf(
|
|
||||||
"https://test.org" to aWellKnown().copy(slidingSyncProxy = null),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
val changeServerPresenter = ChangeServerPresenter(
|
|
||||||
FakeMatrixAuthenticationService(),
|
|
||||||
AccountProviderDataSource()
|
|
||||||
)
|
|
||||||
val presenter = SearchAccountProviderPresenter(
|
|
||||||
HomeserverResolver(testCoroutineDispatchers(), fakeWellknownRequest),
|
|
||||||
changeServerPresenter
|
|
||||||
)
|
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
|
||||||
presenter.present()
|
|
||||||
}.test {
|
|
||||||
val initialState = awaitItem()
|
|
||||||
initialState.eventSink.invoke(SearchAccountProviderEvents.UserInput("test"))
|
|
||||||
val withInputState = awaitItem()
|
|
||||||
assertThat(withInputState.userInput).isEqualTo("test")
|
|
||||||
assertThat(initialState.userInputResult).isEqualTo(AsyncData.Uninitialized)
|
|
||||||
assertThat(awaitItem().userInputResult).isInstanceOf(AsyncData.Loading::class.java)
|
|
||||||
assertThat(awaitItem().userInputResult).isEqualTo(
|
|
||||||
AsyncData.Success(
|
|
||||||
listOf(
|
|
||||||
aHomeserverData(homeserverUrl = "https://test.org", isWellknownValid = true, supportSlidingSync = false)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `present - enter text one result with sliding sync`() = runTest {
|
|
||||||
val fakeWellknownRequest = FakeWellknownRequest()
|
val fakeWellknownRequest = FakeWellknownRequest()
|
||||||
fakeWellknownRequest.givenResultMap(
|
fakeWellknownRequest.givenResultMap(
|
||||||
mapOf(
|
mapOf(
|
||||||
|
|
@ -183,9 +147,6 @@ class SearchAccountProviderPresenterTest {
|
||||||
identityServer = WellKnownBaseConfig(
|
identityServer = WellKnownBaseConfig(
|
||||||
baseURL = A_HOMESERVER_URL
|
baseURL = A_HOMESERVER_URL
|
||||||
),
|
),
|
||||||
slidingSyncProxy = WellKnownSlidingSyncConfig(
|
|
||||||
url = A_HOMESERVER_URL
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue