Adds filter event to opt in to thread notifications
This commit is contained in:
parent
ed9ecb7fc9
commit
2379ce673b
|
@ -47,11 +47,10 @@ data class RoomSync(
|
|||
*/
|
||||
@Json(name = "unread_notifications") val unreadNotifications: RoomSyncUnreadNotifications? = null,
|
||||
|
||||
|
||||
/**
|
||||
* The count of threads with unread notifications (not the total # of notifications in all threads)
|
||||
*/
|
||||
@Json(name = "org.matrix.msc3773.unread_thread_notifications") val unreadThreadNotifications: Map<String, RoomSyncUnreadThreadNotifications>? = null,
|
||||
@Json(name = "unread_thread_notifications") val unreadThreadNotifications: Map<String, RoomSyncUnreadThreadNotifications>? = null,
|
||||
|
||||
/**
|
||||
* The room summary.
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo036
|
|||
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo037
|
||||
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo038
|
||||
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo039
|
||||
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo041
|
||||
import org.matrix.android.sdk.internal.util.Normalizer
|
||||
import org.matrix.android.sdk.internal.util.database.MatrixRealmMigration
|
||||
import javax.inject.Inject
|
||||
|
@ -64,7 +65,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
|
|||
private val normalizer: Normalizer
|
||||
) : MatrixRealmMigration(
|
||||
dbName = "Session",
|
||||
schemaVersion = 39L,
|
||||
schemaVersion = 41L,
|
||||
) {
|
||||
/**
|
||||
* Forces all RealmSessionStoreMigration instances to be equal.
|
||||
|
@ -113,5 +114,6 @@ internal class RealmSessionStoreMigration @Inject constructor(
|
|||
if (oldVersion < 37) MigrateSessionTo037(realm).perform()
|
||||
if (oldVersion < 38) MigrateSessionTo038(realm).perform()
|
||||
if (oldVersion < 39) MigrateSessionTo039(realm).perform()
|
||||
if (oldVersion < 41) MigrateSessionTo041(realm).perform()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.database.migration
|
||||
|
||||
import io.realm.DynamicRealm
|
||||
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
|
||||
import org.matrix.android.sdk.internal.util.database.RealmMigrator
|
||||
|
||||
internal class MigrateSessionTo041(realm: DynamicRealm) : RealmMigrator(realm, 41) {
|
||||
|
||||
override fun doMigrate(realm: DynamicRealm) {
|
||||
realm.schema.get("RoomSummaryEntity")
|
||||
?.addField(RoomSummaryEntityFields.THREAD_HIGHLIGHT_COUNT, Int::class.java)
|
||||
?.addField(RoomSummaryEntityFields.THREAD_NOTIFICATION_COUNT, Int::class.java)
|
||||
}
|
||||
}
|
|
@ -110,8 +110,7 @@ internal fun RealmQuery<TimelineEventEntity>.filterEvents(filters: TimelineEvent
|
|||
endGroup()
|
||||
}
|
||||
if (filters.filterUseless) {
|
||||
not()
|
||||
.equalTo(TimelineEventEntityFields.ROOT.IS_USELESS, true)
|
||||
not().equalTo(TimelineEventEntityFields.ROOT.IS_USELESS, true)
|
||||
}
|
||||
if (filters.filterEdits) {
|
||||
not().like(TimelineEventEntityFields.ROOT.CONTENT, TimelineEventFilter.Content.EDIT)
|
||||
|
|
|
@ -29,7 +29,6 @@ internal object FilterFactory {
|
|||
// senders = listOf(userId),
|
||||
// relationSenders = userId?.let { listOf(it) },
|
||||
relationTypes = listOf(RelationType.THREAD),
|
||||
enableUnreadThreadNotifications = true,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -39,7 +38,6 @@ internal object FilterFactory {
|
|||
containsUrl = true,
|
||||
types = listOf(EventType.MESSAGE),
|
||||
lazyLoadMembers = true,
|
||||
enableUnreadThreadNotifications = true,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -57,32 +55,23 @@ internal object FilterFactory {
|
|||
}
|
||||
|
||||
fun createDefaultRoomFilter(): RoomEventFilter {
|
||||
return RoomEventFilter(
|
||||
lazyLoadMembers = true
|
||||
)
|
||||
return RoomEventFilter(lazyLoadMembers = true)
|
||||
}
|
||||
|
||||
fun createElementRoomFilter(): RoomEventFilter {
|
||||
return RoomEventFilter(
|
||||
lazyLoadMembers = true,
|
||||
enableUnreadThreadNotifications = true,
|
||||
// TODO Enable this for optimization
|
||||
// types = (listOfSupportedEventTypes + listOfSupportedStateEventTypes).toMutableList()
|
||||
)
|
||||
}
|
||||
|
||||
private fun createElementTimelineFilter(): RoomEventFilter? {
|
||||
return null // RoomEventFilter().apply {
|
||||
// TODO Enable this for optimization
|
||||
// types = listOfSupportedEventTypes.toMutableList()
|
||||
// }
|
||||
return RoomEventFilter(enableUnreadThreadNotifications = true)
|
||||
}
|
||||
|
||||
private fun createElementStateFilter(): RoomEventFilter {
|
||||
return RoomEventFilter(
|
||||
lazyLoadMembers = true,
|
||||
enableUnreadThreadNotifications = true,
|
||||
)
|
||||
return RoomEventFilter(lazyLoadMembers = true)
|
||||
}
|
||||
|
||||
// Get only managed types by Element
|
||||
|
|
|
@ -81,7 +81,7 @@ internal data class RoomEventFilter(
|
|||
/**
|
||||
* If true, this will opt-in for the server to return unread threads notifications in [RoomSync]
|
||||
*/
|
||||
@Json(name = "org.matrix.msc3773.unread_thread_notifications") val enableUnreadThreadNotifications: Boolean? = null,
|
||||
@Json(name = "unread_thread_notifications") val enableUnreadThreadNotifications: Boolean? = null,
|
||||
) {
|
||||
|
||||
fun toJSONString(): String {
|
||||
|
|
|
@ -140,7 +140,7 @@ internal class DefaultSyncTask @Inject constructor(
|
|||
executeRequest(globalErrorReceiver) {
|
||||
syncAPI.sync(
|
||||
params = requestParams,
|
||||
readTimeOut = readTimeOut
|
||||
readTimeOut = readTimeOut,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ internal class DefaultSyncTask @Inject constructor(
|
|||
syncRequestStateTracker.setSyncRequestState(
|
||||
SyncRequestState.IncrementalSyncParsing(
|
||||
rooms = nbRooms,
|
||||
toDevice = nbToDevice
|
||||
toDevice = nbToDevice,
|
||||
)
|
||||
)
|
||||
syncResponseHandler.handleResponse(syncResponse, token, null)
|
||||
|
|
Loading…
Reference in New Issue