Move code to TimelineEventEntityQueries.kt (#5810)
This commit is contained in:
parent
aebdee1070
commit
7f09a37503
|
@ -132,3 +132,14 @@ internal fun RealmQuery<TimelineEventEntity>.filterSendStates(sendStates: List<S
|
||||||
val sendStatesStr = sendStates.map { it.name }.toTypedArray()
|
val sendStatesStr = sendStates.map { it.name }.toTypedArray()
|
||||||
return `in`(TimelineEventEntityFields.ROOT.SEND_STATE_STR, sendStatesStr)
|
return `in`(TimelineEventEntityFields.ROOT.SEND_STATE_STR, sendStatesStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find all TimelineEventEntity items where sender is in senderIds collection, excluding state events
|
||||||
|
*/
|
||||||
|
internal fun TimelineEventEntity.Companion.findAllFrom(realm: Realm,
|
||||||
|
senderIds: Collection<String>): RealmResults<TimelineEventEntity> {
|
||||||
|
return realm.where(TimelineEventEntity::class.java)
|
||||||
|
.`in`(TimelineEventEntityFields.ROOT.SENDER, senderIds.toTypedArray())
|
||||||
|
.isNull(TimelineEventEntityFields.ROOT.STATE_KEY)
|
||||||
|
.findAll()
|
||||||
|
}
|
||||||
|
|
|
@ -43,10 +43,10 @@ import org.matrix.android.sdk.internal.database.model.PushRulesEntity
|
||||||
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
|
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
|
||||||
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
|
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
|
||||||
import org.matrix.android.sdk.internal.database.model.TimelineEventEntity
|
import org.matrix.android.sdk.internal.database.model.TimelineEventEntity
|
||||||
import org.matrix.android.sdk.internal.database.model.TimelineEventEntityFields
|
|
||||||
import org.matrix.android.sdk.internal.database.model.UserAccountDataEntity
|
import org.matrix.android.sdk.internal.database.model.UserAccountDataEntity
|
||||||
import org.matrix.android.sdk.internal.database.model.UserAccountDataEntityFields
|
import org.matrix.android.sdk.internal.database.model.UserAccountDataEntityFields
|
||||||
import org.matrix.android.sdk.internal.database.model.deleteOnCascade
|
import org.matrix.android.sdk.internal.database.model.deleteOnCascade
|
||||||
|
import org.matrix.android.sdk.internal.database.query.findAllFrom
|
||||||
import org.matrix.android.sdk.internal.database.query.getDirectRooms
|
import org.matrix.android.sdk.internal.database.query.getDirectRooms
|
||||||
import org.matrix.android.sdk.internal.database.query.getOrCreate
|
import org.matrix.android.sdk.internal.database.query.getOrCreate
|
||||||
import org.matrix.android.sdk.internal.database.query.where
|
import org.matrix.android.sdk.internal.database.query.where
|
||||||
|
@ -206,10 +206,7 @@ internal class UserAccountDataSyncHandler @Inject constructor(
|
||||||
// See https://spec.matrix.org/latest/client-server-api/#client-behaviour-22 :
|
// See https://spec.matrix.org/latest/client-server-api/#client-behaviour-22 :
|
||||||
// "Once ignored, the client will no longer receive events sent by that user, with the exception of state events"
|
// "Once ignored, the client will no longer receive events sent by that user, with the exception of state events"
|
||||||
// So just delete all non-state events from our local storage.
|
// So just delete all non-state events from our local storage.
|
||||||
realm.where(TimelineEventEntity::class.java)
|
TimelineEventEntity.findAllFrom(realm, userIds)
|
||||||
.`in`(TimelineEventEntityFields.ROOT.SENDER, userIds.toTypedArray())
|
|
||||||
.isNull(TimelineEventEntityFields.ROOT.STATE_KEY)
|
|
||||||
.findAll()
|
|
||||||
.also { Timber.d("Deleting ${it.size} TimelineEventEntity from ignored users") }
|
.also { Timber.d("Deleting ${it.size} TimelineEventEntity from ignored users") }
|
||||||
.forEach {
|
.forEach {
|
||||||
it.deleteOnCascade(true)
|
it.deleteOnCascade(true)
|
||||||
|
|
Loading…
Reference in New Issue