Skip to content

Commit c919618

Browse files
authored
Fix account provider change on nightly and release (#861)
* Use parallelMap (same code) * Add proguard rules. Fixes #818 * Rename file proguard-rules.pro to consumer-rules.pro for coherency. * Remove empty and non-referenced proguard files.
1 parent 106d070 commit c919618

File tree

13 files changed

+59
-193
lines changed

13 files changed

+59
-193
lines changed

features/login/impl/src/main/kotlin/io/element/android/features/login/impl/resolver/HomeserverResolver.kt

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ package io.element.android.features.login.impl.resolver
1919
import io.element.android.features.login.impl.resolver.network.WellknownRequest
2020
import io.element.android.libraries.core.bool.orFalse
2121
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
22+
import io.element.android.libraries.core.coroutine.parallelMap
2223
import io.element.android.libraries.core.data.tryOrNull
2324
import io.element.android.libraries.core.uri.ensureProtocol
2425
import io.element.android.libraries.core.uri.isValidUrl
25-
import kotlinx.coroutines.async
26-
import kotlinx.coroutines.awaitAll
2726
import kotlinx.coroutines.currentCoroutineContext
2827
import kotlinx.coroutines.flow.Flow
2928
import kotlinx.coroutines.flow.flow
@@ -49,30 +48,28 @@ class HomeserverResolver @Inject constructor(
4948
val currentList = Collections.synchronizedList(mutableListOf<HomeserverData>())
5049
// Run all the requests in parallel
5150
withContext(dispatchers.io) {
52-
list.map { url ->
53-
async {
54-
val wellKnown = tryOrNull {
55-
withTimeout(5000) {
56-
wellknownRequest.execute(url)
57-
}
51+
list.parallelMap { url ->
52+
val wellKnown = tryOrNull {
53+
withTimeout(5000) {
54+
wellknownRequest.execute(url)
5855
}
59-
val isValid = wellKnown?.isValid().orFalse()
60-
if (isValid) {
61-
val supportSlidingSync = wellKnown?.supportSlidingSync().orFalse()
62-
// Emit the list as soon as possible
63-
currentList.add(
64-
HomeserverData(
65-
homeserverUrl = url,
66-
isWellknownValid = true,
67-
supportSlidingSync = supportSlidingSync
68-
)
56+
}
57+
val isValid = wellKnown?.isValid().orFalse()
58+
if (isValid) {
59+
val supportSlidingSync = wellKnown?.supportSlidingSync().orFalse()
60+
// Emit the list as soon as possible
61+
currentList.add(
62+
HomeserverData(
63+
homeserverUrl = url,
64+
isWellknownValid = true,
65+
supportSlidingSync = supportSlidingSync
6966
)
70-
withContext(flowContext) {
71-
emit(currentList.toList())
72-
}
67+
)
68+
withContext(flowContext) {
69+
emit(currentList.toList())
7370
}
7471
}
75-
}.awaitAll()
72+
}
7673
}
7774
// If list is empty, and the user has entered an URL, do not block the user.
7875
if (currentList.isEmpty() && trimmedUserInput.isValidUrl()) {

features/messages/impl/proguard-rules.pro

Lines changed: 0 additions & 21 deletions
This file was deleted.

libraries/androidutils/proguard-rules.pro

Lines changed: 0 additions & 21 deletions
This file was deleted.

libraries/dateformatter/api/proguard-rules.pro

Lines changed: 0 additions & 21 deletions
This file was deleted.

libraries/dateformatter/impl/proguard-rules.pro

Lines changed: 0 additions & 21 deletions
This file was deleted.

libraries/dateformatter/test/proguard-rules.pro

Lines changed: 0 additions & 21 deletions
This file was deleted.

libraries/designsystem/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ android {
3030
buildTypes {
3131
getByName("release") {
3232
isMinifyEnabled = true
33-
consumerProguardFiles("proguard-rules.pro")
33+
consumerProguardFiles("consumer-rules.pro")
3434
}
3535
}
3636

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.kts.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
22+
23+
-keep class io.element.android.libraries.designsystem.showkase.DesignSystemShowkaseRootModuleCodegen { }

libraries/designsystem/proguard-rules.pro

Lines changed: 0 additions & 23 deletions
This file was deleted.

libraries/network/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ plugins {
2020

2121
android {
2222
namespace = "io.element.android.libraries.network"
23+
24+
buildTypes {
25+
release {
26+
isMinifyEnabled = true
27+
consumerProguardFiles("consumer-rules.pro")
28+
}
29+
}
2330
}
2431

2532
anvil {

0 commit comments

Comments
 (0)