diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt index 015b95e214..b3b98847ed 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt @@ -21,6 +21,7 @@ import androidx.lifecycle.ProcessLifecycleOwner import com.zhuinden.monarchy.Monarchy import im.vector.matrix.android.api.auth.Authenticator import im.vector.matrix.android.api.session.Session +import im.vector.matrix.android.api.session.sync.FilterService import im.vector.matrix.android.internal.auth.AuthModule import im.vector.matrix.android.internal.di.MatrixKoinComponent import im.vector.matrix.android.internal.di.MatrixKoinHolder @@ -53,6 +54,7 @@ class Matrix private constructor(context: Context) : MatrixKoinComponent { authenticator.getLastActiveSession()?.also { currentSession = it it.open() + it.setFilter(FilterService.FilterPreset.RiotFilter) it.startSync() } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/FilterEntityQueries.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/FilterEntityQueries.kt index d69fb34a0f..8fbbb1311e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/FilterEntityQueries.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/FilterEntityQueries.kt @@ -27,7 +27,6 @@ import io.realm.kotlin.where */ internal fun FilterEntity.Companion.getFilter(realm: Realm): FilterEntity { var filter = realm.where().findFirst() - if (filter == null) { realm.executeTransaction { realm.createObject().apply { @@ -36,7 +35,6 @@ internal fun FilterEntity.Companion.getFilter(realm: Realm): FilterEntity { filterId = "" } } - filter = realm.where().findFirst()!! } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterFactory.kt index 7c03ebbd87..d5c93ac350 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterFactory.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/filter/FilterFactory.kt @@ -23,19 +23,15 @@ internal object FilterFactory { fun createDefaultFilterBody(): FilterBody { val filterBody = FilterBody() FilterUtil.enableLazyLoading(filterBody, true) - return filterBody } fun createRiotFilterBody(): FilterBody { val filterBody = FilterBody() - filterBody.room = RoomFilter().apply { timeline = createRiotTimelineFilter() - // TODO Enable this for optimization - // state = createRiotStateFilter() + state = createRiotStateFilter() } - return filterBody } @@ -55,7 +51,6 @@ internal object FilterFactory { private fun createRiotTimelineFilter(): RoomEventFilter { return RoomEventFilter().apply { - lazyLoadMembers = true // TODO Enable this for optimization // types = listOfSupportedEventTypes.toMutableList() } @@ -63,7 +58,7 @@ internal object FilterFactory { private fun createRiotStateFilter(): RoomEventFilter { return RoomEventFilter().apply { - types = listOfSupportedStateEventTypes.toMutableList() + lazyLoadMembers = true } } diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt b/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt index b1cd3f39b1..03529618df 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/HomeActivityViewModel.kt @@ -60,10 +60,6 @@ class HomeActivityViewModel(state: EmptyState, init { session.addListener(this) - - // TODO Move this else where, it's too late when we are here to change the filter - session.setFilter(FilterService.FilterPreset.RiotFilter) - val lastSelectedRoomId = roomSelectionRepository.lastSelectedRoom() if (lastSelectedRoomId == null || session.getRoom(lastSelectedRoomId) == null) { getTheFirstRoomWhenAvailable()