Merge pull request #3609 from element-hq/feature/bma/slidingSyncCheck
Remove supportSlidingSync boolean.
This commit is contained in:
commit
643c9c7f39
17 changed files with 15 additions and 99 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
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:5395f34b153a3c453c95970f326e701e7e5619b53b9bf38dd6a9cff107e28407
|
oid sha256:5fb195657c1ac0379839bba6acc0935f6b1b946714ba252d5797fd4bc0c514db
|
||||||
size 8460
|
size 6753
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:5fb195657c1ac0379839bba6acc0935f6b1b946714ba252d5797fd4bc0c514db
|
oid sha256:6d742af6422e7f5ce0070831e921180006a5b48d52c042fdc52030435597f242
|
||||||
size 6753
|
size 5835
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:6d742af6422e7f5ce0070831e921180006a5b48d52c042fdc52030435597f242
|
|
||||||
size 5835
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:daed25bb59f0cca8d4bdb5139a177904a407b7d42f9e2d7053fd6f7362c141bf
|
oid sha256:ec5654de38a98ee4b078aa3dfa093a686cb89a2f200eb69f59e78041eb8b2f60
|
||||||
size 8372
|
size 6743
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:ec5654de38a98ee4b078aa3dfa093a686cb89a2f200eb69f59e78041eb8b2f60
|
oid sha256:b4731443df36855c8785072a8085fc9968ec231ff46ff24012b0ae72cd084e46
|
||||||
size 6743
|
size 5867
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:b4731443df36855c8785072a8085fc9968ec231ff46ff24012b0ae72cd084e46
|
|
||||||
size 5867
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue