Skip to content

Commit e5874e4

Browse files
committed
Merge branch 'hotfix/1.3.18' into main
2 parents f187216 + fd306e1 commit e5874e4

File tree

7 files changed

+35
-5
lines changed

7 files changed

+35
-5
lines changed

CHANGES.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Changes in Element v1.3.18 (2022-02-03)
2+
=======================================
3+
4+
Bugfixes 🐛
5+
----------
6+
- Avoid deleting root event of CurrentState on gappy sync. In order to restore lost Events an initial sync may be triggered. ([#5137](https://github.com/vector-im/element-android/issues/5137))
7+
8+
19
Changes in Element v1.3.17 (2022-01-31)
210
=======================================
311

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Main changes in this version: send your location to any room. Edit poll.
2+
Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.18

matrix-sdk-android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ android {
3131
// that the app's state is completely cleared between tests.
3232
testInstrumentationRunnerArguments clearPackageData: 'true'
3333

34-
buildConfigField "String", "SDK_VERSION", "\"1.3.17\""
34+
buildConfigField "String", "SDK_VERSION", "\"1.3.18\""
3535

3636
buildConfigField "String", "GIT_SDK_REVISION", "\"${gitRevision()}\""
3737
resValue "string", "git_sdk_revision", "\"${gitRevision()}\""

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt

+18-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
5656
) : RealmMigration {
5757

5858
companion object {
59-
const val SESSION_STORE_SCHEMA_VERSION = 21L
59+
const val SESSION_STORE_SCHEMA_VERSION = 22L
6060
}
6161

6262
/**
@@ -90,6 +90,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
9090
if (oldVersion <= 18) migrateTo19(realm)
9191
if (oldVersion <= 19) migrateTo20(realm)
9292
if (oldVersion <= 20) migrateTo21(realm)
93+
if (oldVersion <= 21) migrateTo22(realm)
9394
}
9495

9596
private fun migrateTo1(realm: DynamicRealm) {
@@ -445,4 +446,20 @@ internal class RealmSessionStoreMigration @Inject constructor(
445446
}
446447
}
447448
}
449+
450+
private fun migrateTo22(realm: DynamicRealm) {
451+
Timber.d("Step 21 -> 22")
452+
val listJoinedRoomIds = realm.where("RoomEntity")
453+
.equalTo(RoomEntityFields.MEMBERSHIP_STR, Membership.JOIN.name).findAll()
454+
.map { it.getString(RoomEntityFields.ROOM_ID) }
455+
456+
val hasMissingStateEvent = realm.where("CurrentStateEventEntity")
457+
.`in`(CurrentStateEventEntityFields.ROOM_ID, listJoinedRoomIds.toTypedArray())
458+
.isNull(CurrentStateEventEntityFields.ROOT.`$`).findFirst() != null
459+
460+
if (hasMissingStateEvent) {
461+
Timber.v("Has some missing state event, clear session cache")
462+
realm.deleteAll()
463+
}
464+
}
448465
}

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/ChunkEntity.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ internal fun ChunkEntity.deleteOnCascade(deleteStateEvents: Boolean, canDeleteRo
5252
if (deleteStateEvents) {
5353
stateEvents.deleteAllFromRealm()
5454
}
55-
timelineEvents.clearWith { it.deleteOnCascade(canDeleteRoot) }
55+
timelineEvents.clearWith {
56+
val deleteRoot = canDeleteRoot && (it.root?.stateKey == null || deleteStateEvents)
57+
it.deleteOnCascade(deleteRoot)
58+
}
5659
deleteFromRealm()
5760
}

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomSyncHandler.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle
350350
aggregator: SyncResponsePostTreatmentAggregator): ChunkEntity {
351351
val lastChunk = ChunkEntity.findLastForwardChunkOfRoom(realm, roomEntity.roomId)
352352
if (isLimited && lastChunk != null) {
353-
lastChunk.deleteOnCascade(deleteStateEvents = true, canDeleteRoot = true)
353+
lastChunk.deleteOnCascade(deleteStateEvents = false, canDeleteRoot = true)
354354
}
355355
val chunkEntity = if (!isLimited && lastChunk != null) {
356356
lastChunk

vector/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ext.versionMinor = 3
1818
// Note: even values are reserved for regular release, odd values for hotfix release.
1919
// When creating a hotfix, you should decrease the value, since the current value
2020
// is the value for the next regular release.
21-
ext.versionPatch = 17
21+
ext.versionPatch = 18
2222

2323
static def getGitTimestamp() {
2424
def cmd = 'git show -s --format=%ct'

0 commit comments

Comments
 (0)