Merge pull request #3609 from element-hq/feature/bma/slidingSyncCheck
Remove supportSlidingSync boolean.
This commit is contained in:
@@ -14,5 +14,4 @@ data class AccountProvider(
|
||||
val isPublic: Boolean = false,
|
||||
val isMatrixOrg: Boolean = false,
|
||||
val isValid: Boolean = false,
|
||||
val supportSlidingSync: Boolean = false,
|
||||
)
|
||||
|
||||
@@ -15,8 +15,7 @@ open class AccountProviderProvider : PreviewParameterProvider<AccountProvider> {
|
||||
get() = sequenceOf(
|
||||
anAccountProvider(),
|
||||
anAccountProvider().copy(subtitle = null),
|
||||
anAccountProvider().copy(subtitle = null, title = "no.sliding.sync", supportSlidingSync = false),
|
||||
anAccountProvider().copy(subtitle = null, title = "invalid", isValid = false, supportSlidingSync = false),
|
||||
anAccountProvider().copy(subtitle = null, title = "invalid", isValid = false),
|
||||
anAccountProvider().copy(subtitle = null, title = "Other", isPublic = false, isMatrixOrg = false),
|
||||
// Add other state here
|
||||
)
|
||||
@@ -28,5 +27,4 @@ fun anAccountProvider() = AccountProvider(
|
||||
isPublic = true,
|
||||
isMatrixOrg = true,
|
||||
isValid = true,
|
||||
supportSlidingSync = true,
|
||||
)
|
||||
|
||||
@@ -12,6 +12,4 @@ data class HomeserverData(
|
||||
val homeserverUrl: String,
|
||||
// True if a wellknown file has been found and is valid. If false, it means that the [homeserverUrl] is valid
|
||||
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 wellknownRequest: WellknownRequest,
|
||||
) {
|
||||
suspend fun resolve(userInput: String): Flow<List<HomeserverData>> = flow {
|
||||
fun resolve(userInput: String): Flow<List<HomeserverData>> = flow {
|
||||
val flowContext = currentCoroutineContext()
|
||||
val trimmedUserInput = userInput.trim()
|
||||
if (trimmedUserInput.length < 4) return@flow
|
||||
@@ -46,13 +46,11 @@ class HomeserverResolver @Inject constructor(
|
||||
}
|
||||
val isValid = wellKnown?.isValid().orFalse()
|
||||
if (isValid) {
|
||||
val supportSlidingSync = wellKnown?.supportSlidingSync().orFalse()
|
||||
// Emit the list as soon as possible
|
||||
currentList.add(
|
||||
HomeserverData(
|
||||
homeserverUrl = url,
|
||||
isWellknownValid = true,
|
||||
supportSlidingSync = supportSlidingSync
|
||||
)
|
||||
)
|
||||
withContext(flowContext) {
|
||||
@@ -68,7 +66,6 @@ class HomeserverResolver @Inject constructor(
|
||||
HomeserverData(
|
||||
homeserverUrl = trimmedUserInput,
|
||||
isWellknownValid = false,
|
||||
supportSlidingSync = false,
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -21,9 +21,6 @@ import kotlinx.serialization.Serializable
|
||||
* "m.identity_server": {
|
||||
* "base_url": "https://vector.im"
|
||||
* },
|
||||
* "org.matrix.msc3575.proxy": {
|
||||
* "url": "https://slidingsync.lab.matrix.org"
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* .
|
||||
@@ -34,14 +31,8 @@ data class WellKnown(
|
||||
val homeServer: WellKnownBaseConfig? = null,
|
||||
@SerialName("m.identity_server")
|
||||
val identityServer: WellKnownBaseConfig? = null,
|
||||
@SerialName("org.matrix.msc3575.proxy")
|
||||
val slidingSyncProxy: WellKnownSlidingSyncConfig? = null,
|
||||
) {
|
||||
fun isValid(): Boolean {
|
||||
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,
|
||||
isMatrixOrg = true,
|
||||
isValid = true,
|
||||
supportSlidingSync = true,
|
||||
)
|
||||
),
|
||||
changeServerState = changeServerState,
|
||||
|
||||
@@ -34,20 +34,18 @@ fun aSearchAccountProviderState(
|
||||
|
||||
fun aHomeserverDataList(): List<HomeserverData> {
|
||||
return listOf(
|
||||
aHomeserverData(isWellknownValid = true, supportSlidingSync = true),
|
||||
aHomeserverData(homeserverUrl = "https://no.sliding.sync", isWellknownValid = true, supportSlidingSync = false),
|
||||
aHomeserverData(homeserverUrl = "https://invalid", isWellknownValid = false, supportSlidingSync = false),
|
||||
aHomeserverData(isWellknownValid = true),
|
||||
aHomeserverData(homeserverUrl = "https://no.sliding.sync", isWellknownValid = true),
|
||||
aHomeserverData(homeserverUrl = "https://invalid", isWellknownValid = false),
|
||||
)
|
||||
}
|
||||
|
||||
fun aHomeserverData(
|
||||
homeserverUrl: String = AuthenticationConfig.MATRIX_ORG_URL,
|
||||
isWellknownValid: Boolean = true,
|
||||
supportSlidingSync: Boolean = true,
|
||||
): HomeserverData {
|
||||
return HomeserverData(
|
||||
homeserverUrl = homeserverUrl,
|
||||
isWellknownValid = isWellknownValid,
|
||||
supportSlidingSync = supportSlidingSync,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -196,7 +196,6 @@ private fun HomeserverData.toAccountProvider(): AccountProvider {
|
||||
isPublic = isMatrixOrg,
|
||||
isMatrixOrg = isMatrixOrg,
|
||||
isValid = isWellknownValid,
|
||||
supportSlidingSync = supportSlidingSync,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ class ChangeAccountProviderPresenterTest {
|
||||
isPublic = true,
|
||||
isMatrixOrg = 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.WellKnown
|
||||
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.matrix.test.A_HOMESERVER_URL
|
||||
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
|
||||
@@ -98,7 +97,7 @@ class SearchAccountProviderPresenterTest {
|
||||
assertThat(awaitItem().userInputResult).isEqualTo(
|
||||
AsyncData.Success(
|
||||
listOf(
|
||||
aHomeserverData(homeserverUrl = "https://test.org", isWellknownValid = false, supportSlidingSync = false)
|
||||
aHomeserverData(homeserverUrl = "https://test.org", isWellknownValid = false)
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -106,42 +105,7 @@ class SearchAccountProviderPresenterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - enter text one result no sliding sync`() = 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 {
|
||||
fun `present - enter text one result with wellknown`() = runTest {
|
||||
val fakeWellknownRequest = FakeWellknownRequest()
|
||||
fakeWellknownRequest.givenResultMap(
|
||||
mapOf(
|
||||
@@ -183,9 +147,6 @@ class SearchAccountProviderPresenterTest {
|
||||
identityServer = WellKnownBaseConfig(
|
||||
baseURL = A_HOMESERVER_URL
|
||||
),
|
||||
slidingSyncProxy = WellKnownSlidingSyncConfig(
|
||||
url = A_HOMESERVER_URL
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user