Skip to content

Commit

Permalink
Merge branch 'hotfix/1.3.18' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Feb 3, 2022
2 parents f187216 + fd306e1 commit e5874e4
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Changes in Element v1.3.18 (2022-02-03)
=======================================

Bugfixes 🐛
----------
- 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))


Changes in Element v1.3.17 (2022-01-31)
=======================================

Expand Down
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/40103180.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Main changes in this version: send your location to any room. Edit poll.
Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.18
2 changes: 1 addition & 1 deletion matrix-sdk-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'

buildConfigField "String", "SDK_VERSION", "\"1.3.17\""
buildConfigField "String", "SDK_VERSION", "\"1.3.18\""

buildConfigField "String", "GIT_SDK_REVISION", "\"${gitRevision()}\""
resValue "string", "git_sdk_revision", "\"${gitRevision()}\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
) : RealmMigration {

companion object {
const val SESSION_STORE_SCHEMA_VERSION = 21L
const val SESSION_STORE_SCHEMA_VERSION = 22L
}

/**
Expand Down Expand Up @@ -90,6 +90,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
if (oldVersion <= 18) migrateTo19(realm)
if (oldVersion <= 19) migrateTo20(realm)
if (oldVersion <= 20) migrateTo21(realm)
if (oldVersion <= 21) migrateTo22(realm)
}

private fun migrateTo1(realm: DynamicRealm) {
Expand Down Expand Up @@ -445,4 +446,20 @@ internal class RealmSessionStoreMigration @Inject constructor(
}
}
}

private fun migrateTo22(realm: DynamicRealm) {
Timber.d("Step 21 -> 22")
val listJoinedRoomIds = realm.where("RoomEntity")
.equalTo(RoomEntityFields.MEMBERSHIP_STR, Membership.JOIN.name).findAll()
.map { it.getString(RoomEntityFields.ROOM_ID) }

val hasMissingStateEvent = realm.where("CurrentStateEventEntity")
.`in`(CurrentStateEventEntityFields.ROOM_ID, listJoinedRoomIds.toTypedArray())
.isNull(CurrentStateEventEntityFields.ROOT.`$`).findFirst() != null

if (hasMissingStateEvent) {
Timber.v("Has some missing state event, clear session cache")
realm.deleteAll()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ internal fun ChunkEntity.deleteOnCascade(deleteStateEvents: Boolean, canDeleteRo
if (deleteStateEvents) {
stateEvents.deleteAllFromRealm()
}
timelineEvents.clearWith { it.deleteOnCascade(canDeleteRoot) }
timelineEvents.clearWith {
val deleteRoot = canDeleteRoot && (it.root?.stateKey == null || deleteStateEvents)
it.deleteOnCascade(deleteRoot)
}
deleteFromRealm()
}
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle
aggregator: SyncResponsePostTreatmentAggregator): ChunkEntity {
val lastChunk = ChunkEntity.findLastForwardChunkOfRoom(realm, roomEntity.roomId)
if (isLimited && lastChunk != null) {
lastChunk.deleteOnCascade(deleteStateEvents = true, canDeleteRoot = true)
lastChunk.deleteOnCascade(deleteStateEvents = false, canDeleteRoot = true)
}
val chunkEntity = if (!isLimited && lastChunk != null) {
lastChunk
Expand Down
2 changes: 1 addition & 1 deletion vector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ext.versionMinor = 3
// Note: even values are reserved for regular release, odd values for hotfix release.
// When creating a hotfix, you should decrease the value, since the current value
// is the value for the next regular release.
ext.versionPatch = 17
ext.versionPatch = 18

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

0 comments on commit e5874e4

Please sign in to comment.