Merge branch 'hotfix/1.4.20' into develop
This commit is contained in:
commit
d876690fc7
|
@ -1,3 +1,12 @@
|
||||||
|
Changes in Element 1.4.20 (2022-06-13)
|
||||||
|
======================================
|
||||||
|
|
||||||
|
Bugfixes 🐛
|
||||||
|
----------
|
||||||
|
- Fix: All rooms are shown in Home regardless of the switch state. ([#6272](https://github.com/vector-im/element-android/issues/6272))
|
||||||
|
- Fix regression on EventInsertLiveObserver getting blocked so there is no event being processed anymore. ([#6278](https://github.com/vector-im/element-android/issues/6278))
|
||||||
|
|
||||||
|
|
||||||
Changes in Element 1.4.19 (2022-06-07)
|
Changes in Element 1.4.19 (2022-06-07)
|
||||||
======================================
|
======================================
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Main changes in this version: Various bug fixes and stability improvements.
|
||||||
|
Full changelog: https://github.com/vector-im/element-android/releases
|
|
@ -19,10 +19,9 @@ package org.matrix.android.sdk.internal.database
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
import io.realm.RealmConfiguration
|
import io.realm.RealmConfiguration
|
||||||
import io.realm.RealmResults
|
import io.realm.RealmResults
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import kotlinx.coroutines.flow.onEach
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.sync.Mutex
|
||||||
|
import kotlinx.coroutines.sync.withLock
|
||||||
import org.matrix.android.sdk.internal.database.mapper.asDomain
|
import org.matrix.android.sdk.internal.database.mapper.asDomain
|
||||||
import org.matrix.android.sdk.internal.database.model.EventEntity
|
import org.matrix.android.sdk.internal.database.model.EventEntity
|
||||||
import org.matrix.android.sdk.internal.database.model.EventInsertEntity
|
import org.matrix.android.sdk.internal.database.model.EventInsertEntity
|
||||||
|
@ -39,26 +38,18 @@ internal class EventInsertLiveObserver @Inject constructor(
|
||||||
) :
|
) :
|
||||||
RealmLiveEntityObserver<EventInsertEntity>(realmConfiguration) {
|
RealmLiveEntityObserver<EventInsertEntity>(realmConfiguration) {
|
||||||
|
|
||||||
|
private val lock = Mutex()
|
||||||
|
|
||||||
override val query = Monarchy.Query {
|
override val query = Monarchy.Query {
|
||||||
it.where(EventInsertEntity::class.java).equalTo(EventInsertEntityFields.CAN_BE_PROCESSED, true)
|
it.where(EventInsertEntity::class.java).equalTo(EventInsertEntityFields.CAN_BE_PROCESSED, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val onResultsChangedFlow = MutableSharedFlow<RealmResults<EventInsertEntity>>()
|
|
||||||
|
|
||||||
init {
|
|
||||||
onResultsChangedFlow
|
|
||||||
.onEach { handleChange(it) }
|
|
||||||
.launchIn(observerScope)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onChange(results: RealmResults<EventInsertEntity>) {
|
override fun onChange(results: RealmResults<EventInsertEntity>) {
|
||||||
|
observerScope.launch {
|
||||||
|
lock.withLock {
|
||||||
if (!results.isLoaded || results.isEmpty()) {
|
if (!results.isLoaded || results.isEmpty()) {
|
||||||
return
|
return@withLock
|
||||||
}
|
}
|
||||||
observerScope.launch { onResultsChangedFlow.emit(results) }
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun handleChange(results: RealmResults<EventInsertEntity>) {
|
|
||||||
val idsToDeleteAfterProcess = ArrayList<String>()
|
val idsToDeleteAfterProcess = ArrayList<String>()
|
||||||
val filteredEvents = ArrayList<EventInsertEntity>(results.size)
|
val filteredEvents = ArrayList<EventInsertEntity>(results.size)
|
||||||
Timber.v("EventInsertEntity updated with ${results.size} results in db")
|
Timber.v("EventInsertEntity updated with ${results.size} results in db")
|
||||||
|
@ -75,7 +66,6 @@ internal class EventInsertLiveObserver @Inject constructor(
|
||||||
}
|
}
|
||||||
idsToDeleteAfterProcess.add(it.eventId)
|
idsToDeleteAfterProcess.add(it.eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
awaitTransaction(realmConfiguration) { realm ->
|
awaitTransaction(realmConfiguration) { realm ->
|
||||||
Timber.v("##Transaction: There are ${filteredEvents.size} events to process ")
|
Timber.v("##Transaction: There are ${filteredEvents.size} events to process ")
|
||||||
filteredEvents.forEach { eventInsert ->
|
filteredEvents.forEach { eventInsert ->
|
||||||
|
@ -99,6 +89,8 @@ internal class EventInsertLiveObserver @Inject constructor(
|
||||||
}
|
}
|
||||||
processors.forEach { it.onPostProcess() }
|
processors.forEach { it.onPostProcess() }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun shouldProcess(eventInsertEntity: EventInsertEntity): Boolean {
|
private fun shouldProcess(eventInsertEntity: EventInsertEntity): Boolean {
|
||||||
return processors.any {
|
return processors.any {
|
||||||
|
|
|
@ -289,7 +289,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
||||||
.launchIn(viewModelScope)
|
.launchIn(viewModelScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun RoomGroupingMethod.BySpace.toActiveSpaceOrOrphanRooms(): SpaceFilter? {
|
private fun RoomGroupingMethod.BySpace.toActiveSpaceOrOrphanRooms(): SpaceFilter {
|
||||||
return spaceSummary?.roomId?.toActiveSpaceOrOrphanRooms()
|
return spaceSummary?.roomId.toActiveSpaceOrOrphanRooms()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,7 +379,7 @@ class RoomListSectionBuilderSpace(
|
||||||
activeSpaceUpdaters.add(object : RoomListViewModel.ActiveSpaceQueryUpdater {
|
activeSpaceUpdaters.add(object : RoomListViewModel.ActiveSpaceQueryUpdater {
|
||||||
override fun updateForSpaceId(roomId: String?) {
|
override fun updateForSpaceId(roomId: String?) {
|
||||||
filteredPagedRoomSummariesLive.queryParams = roomQueryParams.copy(
|
filteredPagedRoomSummariesLive.queryParams = roomQueryParams.copy(
|
||||||
spaceFilter = roomId?.toActiveSpaceOrOrphanRooms()
|
spaceFilter = roomId.toActiveSpaceOrOrphanRooms()
|
||||||
)
|
)
|
||||||
liveQueryParams.update { filteredPagedRoomSummariesLive.queryParams }
|
liveQueryParams.update { filteredPagedRoomSummariesLive.queryParams }
|
||||||
}
|
}
|
||||||
|
@ -445,7 +445,7 @@ class RoomListSectionBuilderSpace(
|
||||||
return when (spaceFilter) {
|
return when (spaceFilter) {
|
||||||
RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL -> {
|
RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL -> {
|
||||||
copy(
|
copy(
|
||||||
spaceFilter = currentSpace?.toActiveSpaceOrOrphanRooms()
|
spaceFilter = currentSpace.toActiveSpaceOrOrphanRooms()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> {
|
RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> {
|
||||||
|
|
Loading…
Reference in New Issue