Skip to content

Commit f2f96e0

Browse files
authored
Bump Rust SDK to v0.2.18 and bump app version (#2836)
* Adapt to changes in SDK: - Remove name from MatrixRoom, we should use displayName instead. - Remove separate invites room list. - Added runBlocking to get the now async NotificationClient from the Rust SDK. - Made some other functions suspend. - Client.resolveRoomAlias now returns a roomId and via parameters, we pass the roomId. * Add logs removal migration again as `AppMigration03` to make sure we don't leak private data in existing logs. * Bump app version to `0.4.12`
1 parent d0923f2 commit f2f96e0

File tree

24 files changed

+111
-79
lines changed

24 files changed

+111
-79
lines changed

features/migration/impl/src/main/kotlin/io/element/android/features/migration/impl/migrations/AppMigration01.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import io.element.android.features.rageshake.api.logs.LogFilesRemover
2121
import io.element.android.libraries.di.AppScope
2222
import javax.inject.Inject
2323

24+
/**
25+
* Remove existing logs from the device to remove any leaks of sensitive data.
26+
*/
2427
@ContributesMultibinding(AppScope::class)
2528
class AppMigration01 @Inject constructor(
2629
private val logFilesRemover: LogFilesRemover,

features/migration/impl/src/main/kotlin/io/element/android/features/migration/impl/migrations/AppMigration02.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import io.element.android.libraries.sessionstorage.api.SessionStore
2424
import kotlinx.coroutines.coroutineScope
2525
import javax.inject.Inject
2626

27+
/**
28+
* This migration sets the skip session verification preference to true for all existing sessions.
29+
* This way we don't force existing users to verify their session again.
30+
*/
2731
@ContributesMultibinding(AppScope::class)
2832
class AppMigration02 @Inject constructor(
2933
private val sessionStore: SessionStore,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2024 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.element.android.features.migration.impl.migrations
18+
19+
import com.squareup.anvil.annotations.ContributesMultibinding
20+
import io.element.android.libraries.di.AppScope
21+
import javax.inject.Inject
22+
23+
/**
24+
* This performs the same operation as [AppMigration01], since we need to clear the local logs again.
25+
*/
26+
@ContributesMultibinding(AppScope::class)
27+
class AppMigration03 @Inject constructor(
28+
private val migration01: AppMigration01,
29+
) : AppMigration {
30+
override val order: Int = 3
31+
32+
override suspend fun migrate() {
33+
migration01.migrate()
34+
}
35+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2024 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.element.android.features.migration.impl.migrations
18+
19+
import io.element.android.features.rageshake.test.logs.FakeLogFilesRemover
20+
import kotlinx.coroutines.test.runTest
21+
import org.junit.Test
22+
23+
class AppMigration03Test {
24+
@Test
25+
fun `test migration`() = runTest {
26+
val logsFileRemover = FakeLogFilesRemover()
27+
val migration = AppMigration03(migration01 = AppMigration01(logsFileRemover))
28+
29+
migration.migrate()
30+
31+
logsFileRemover.performLambda.assertions().isCalledOnce()
32+
}
33+
}

features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/RoomDetailsPresenter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class RoomDetailsPresenter @Inject constructor(
7575

7676
val roomAvatar by remember { derivedStateOf { roomInfo?.avatarUrl ?: room.avatarUrl } }
7777

78-
val roomName by remember { derivedStateOf { (roomInfo?.name ?: room.name ?: room.displayName).trim() } }
78+
val roomName by remember { derivedStateOf { (roomInfo?.name ?: room.displayName).trim() } }
7979
val roomTopic by remember { derivedStateOf { roomInfo?.topic ?: room.topic } }
8080
val isFavorite by remember { derivedStateOf { roomInfo?.isFavorite.orFalse() } }
8181
val isPublic by remember { derivedStateOf { roomInfo?.isPublic.orFalse() } }

features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/edit/RoomDetailsEditPresenter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class RoomDetailsEditPresenter @Inject constructor(
6565
// just erase the local value when the room field has changed
6666
var roomAvatarUri by rememberSaveable(room.avatarUrl) { mutableStateOf(room.avatarUrl?.toUri()) }
6767

68-
var roomName by rememberSaveable { mutableStateOf((room.name ?: room.displayName).trim()) }
68+
var roomName by rememberSaveable { mutableStateOf(room.displayName.trim()) }
6969
var roomTopic by rememberSaveable { mutableStateOf(room.topic?.trim()) }
7070

7171
val saveButtonEnabled by remember(
@@ -76,7 +76,7 @@ class RoomDetailsEditPresenter @Inject constructor(
7676
) {
7777
derivedStateOf {
7878
roomAvatarUri?.toString()?.trim() != room.avatarUrl?.toUri()?.toString()?.trim() ||
79-
roomName.trim() != (room.name ?: room.displayName).trim() ||
79+
roomName.trim() != room.displayName.trim() ||
8080
roomTopic.orEmpty().trim() != room.topic.orEmpty().trim()
8181
}
8282
}
@@ -168,7 +168,7 @@ class RoomDetailsEditPresenter @Inject constructor(
168168
Timber.e(it, "Failed to set room topic")
169169
})
170170
}
171-
if (name.isNotEmpty() && name.trim() != room.name.orEmpty().trim()) {
171+
if (name.isNotEmpty() && name.trim() != room.displayName.trim()) {
172172
results.add(room.setName(name).onFailure {
173173
Timber.e(it, "Failed to set room name")
174174
})

features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/RoomDetailsPresenterTests.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class RoomDetailsPresenterTests {
118118
presenter.test {
119119
val initialState = awaitItem()
120120
assertThat(initialState.roomId).isEqualTo(room.roomId)
121-
assertThat(initialState.roomName).isEqualTo(room.name)
121+
assertThat(initialState.roomName).isEqualTo(room.displayName)
122122
assertThat(initialState.roomAvatarUrl).isEqualTo(room.avatarUrl)
123123
assertThat(initialState.roomTopic).isEqualTo(RoomTopicState.ExistingTopic(room.topic!!))
124124
assertThat(initialState.memberCount).isEqualTo(room.joinedMemberCount)
@@ -148,7 +148,7 @@ class RoomDetailsPresenterTests {
148148

149149
@Test
150150
fun `present - initial state with no room name`() = runTest {
151-
val room = aMatrixRoom(name = null)
151+
val room = aMatrixRoom(displayName = "")
152152
val presenter = createRoomDetailsPresenter(room)
153153
presenter.test {
154154
val initialState = awaitItem()
@@ -476,8 +476,7 @@ class RoomDetailsPresenterTests {
476476

477477
fun aMatrixRoom(
478478
roomId: RoomId = A_ROOM_ID,
479-
name: String? = A_ROOM_NAME,
480-
displayName: String = "A fallback display name",
479+
displayName: String = A_ROOM_NAME,
481480
topic: String? = "A topic",
482481
avatarUrl: String? = "https://matrix.org/avatar.jpg",
483482
isEncrypted: Boolean = true,
@@ -486,7 +485,6 @@ fun aMatrixRoom(
486485
notificationSettingsService: FakeNotificationSettingsService = FakeNotificationSettingsService()
487486
) = FakeMatrixRoom(
488487
roomId = roomId,
489-
name = name,
490488
displayName = displayName,
491489
topic = topic,
492490
avatarUrl = avatarUrl,

features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/edit/RoomDetailsEditPresenterTest.kt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class RoomDetailsEditPresenterTest {
9898
}.test {
9999
val initialState = awaitItem()
100100
assertThat(initialState.roomId).isEqualTo(room.roomId.value)
101-
assertThat(initialState.roomName).isEqualTo(room.name)
101+
assertThat(initialState.roomName).isEqualTo(room.displayName)
102102
assertThat(initialState.roomAvatarUrl).isEqualTo(roomAvatarUri)
103103
assertThat(initialState.roomTopic).isEqualTo(room.topic.orEmpty())
104104
assertThat(initialState.avatarActions).containsExactly(
@@ -191,7 +191,7 @@ class RoomDetailsEditPresenterTest {
191191

192192
@Test
193193
fun `present - updates state in response to changes`() = runTest {
194-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL)
194+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL)
195195
val presenter = createRoomDetailsEditPresenter(room)
196196

197197
moleculeFlow(RecompositionMode.Immediate) {
@@ -234,7 +234,7 @@ class RoomDetailsEditPresenterTest {
234234

235235
@Test
236236
fun `present - obtains avatar uris from gallery`() = runTest {
237-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL)
237+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL)
238238

239239
fakePickerProvider.givenResult(anotherAvatarUri)
240240

@@ -255,7 +255,7 @@ class RoomDetailsEditPresenterTest {
255255

256256
@Test
257257
fun `present - obtains avatar uris from camera`() = runTest {
258-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL)
258+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL)
259259

260260
fakePickerProvider.givenResult(anotherAvatarUri)
261261
val fakePermissionsPresenter = FakePermissionsPresenter()
@@ -288,7 +288,7 @@ class RoomDetailsEditPresenterTest {
288288

289289
@Test
290290
fun `present - updates save button state`() = runTest {
291-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL)
291+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL)
292292

293293
fakePickerProvider.givenResult(roomAvatarUri)
294294

@@ -340,7 +340,7 @@ class RoomDetailsEditPresenterTest {
340340

341341
@Test
342342
fun `present - updates save button state when initial values are null`() = runTest {
343-
val room = aMatrixRoom(topic = null, name = null, displayName = "fallback", avatarUrl = null)
343+
val room = aMatrixRoom(topic = null, displayName = "fallback", avatarUrl = null)
344344

345345
fakePickerProvider.givenResult(roomAvatarUri)
346346

@@ -392,7 +392,7 @@ class RoomDetailsEditPresenterTest {
392392

393393
@Test
394394
fun `present - save changes room details if different`() = runTest {
395-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL)
395+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL)
396396

397397
val presenter = createRoomDetailsEditPresenter(room)
398398

@@ -417,7 +417,7 @@ class RoomDetailsEditPresenterTest {
417417

418418
@Test
419419
fun `present - save doesn't change room details if they're the same trimmed`() = runTest {
420-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL)
420+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL)
421421

422422
val presenter = createRoomDetailsEditPresenter(room)
423423

@@ -441,7 +441,7 @@ class RoomDetailsEditPresenterTest {
441441

442442
@Test
443443
fun `present - save doesn't change topic if it was unset and is now blank`() = runTest {
444-
val room = aMatrixRoom(topic = null, name = "Name", avatarUrl = AN_AVATAR_URL)
444+
val room = aMatrixRoom(topic = null, displayName = "Name", avatarUrl = AN_AVATAR_URL)
445445

446446
val presenter = createRoomDetailsEditPresenter(room)
447447

@@ -464,7 +464,7 @@ class RoomDetailsEditPresenterTest {
464464

465465
@Test
466466
fun `present - save doesn't change name if it's now empty`() = runTest {
467-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL)
467+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL)
468468

469469
val presenter = createRoomDetailsEditPresenter(room)
470470

@@ -487,7 +487,7 @@ class RoomDetailsEditPresenterTest {
487487

488488
@Test
489489
fun `present - save processes and sets avatar when processor returns successfully`() = runTest {
490-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL)
490+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL)
491491

492492
givenPickerReturnsFile()
493493

@@ -511,7 +511,7 @@ class RoomDetailsEditPresenterTest {
511511

512512
@Test
513513
fun `present - save does not set avatar data if processor fails`() = runTest {
514-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL)
514+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL)
515515

516516
fakePickerProvider.givenResult(anotherAvatarUri)
517517
fakeMediaPreProcessor.givenResult(Result.failure(Throwable("Oh no")))
@@ -538,7 +538,7 @@ class RoomDetailsEditPresenterTest {
538538

539539
@Test
540540
fun `present - sets save action to failure if name update fails`() = runTest {
541-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL).apply {
541+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL).apply {
542542
givenSetNameResult(Result.failure(Throwable("!")))
543543
}
544544

@@ -547,7 +547,7 @@ class RoomDetailsEditPresenterTest {
547547

548548
@Test
549549
fun `present - sets save action to failure if topic update fails`() = runTest {
550-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL).apply {
550+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL).apply {
551551
givenSetTopicResult(Result.failure(Throwable("!")))
552552
}
553553

@@ -556,7 +556,7 @@ class RoomDetailsEditPresenterTest {
556556

557557
@Test
558558
fun `present - sets save action to failure if removing avatar fails`() = runTest {
559-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL).apply {
559+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL).apply {
560560
givenRemoveAvatarResult(Result.failure(Throwable("!")))
561561
}
562562

@@ -567,7 +567,7 @@ class RoomDetailsEditPresenterTest {
567567
fun `present - sets save action to failure if setting avatar fails`() = runTest {
568568
givenPickerReturnsFile()
569569

570-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL).apply {
570+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL).apply {
571571
givenUpdateAvatarResult(Result.failure(Throwable("!")))
572572
}
573573

@@ -578,7 +578,7 @@ class RoomDetailsEditPresenterTest {
578578
fun `present - CancelSaveChanges resets save action state`() = runTest {
579579
givenPickerReturnsFile()
580580

581-
val room = aMatrixRoom(topic = "My topic", name = "Name", avatarUrl = AN_AVATAR_URL).apply {
581+
val room = aMatrixRoom(topic = "My topic", displayName = "Name", avatarUrl = AN_AVATAR_URL).apply {
582582
givenSetTopicResult(Result.failure(Throwable("!")))
583583
}
584584

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ jsoup = "org.jsoup:jsoup:1.17.2"
159159
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
160160
molecule-runtime = "app.cash.molecule:molecule-runtime:1.4.2"
161161
timber = "com.jakewharton.timber:timber:5.0.1"
162-
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.16"
162+
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.18"
163163
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
164164
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
165165
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }

libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/MatrixRoom.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import java.io.File
4444
interface MatrixRoom : Closeable {
4545
val sessionId: SessionId
4646
val roomId: RoomId
47-
val name: String?
4847
val displayName: String
4948
val alias: RoomAlias?
5049
val alternativeAliases: List<RoomAlias>

0 commit comments

Comments
 (0)