Fix performance issues with Spaces on very large accounts #4898

- Listen to `MXSpaceNotificationCounter` to update the notification badge
This commit is contained in:
Gil Eluard
2021-10-07 07:16:15 +02:00
parent f4317e9b0d
commit cf910b0f91
@@ -53,6 +53,8 @@ final class SpaceListViewModel: SpaceListViewModelType {
self.userSessionsService = userSessionsService
NotificationCenter.default.addObserver(self, selector: #selector(self.sessionDidSync(notification:)), name: MXSpaceService.didBuildSpaceGraph, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.counterDidUpdateNotificationCount(notification:)), name: MXSpaceNotificationCounter.didUpdateNotificationCount, object: nil)
}
@@ -122,6 +124,10 @@ final class SpaceListViewModel: SpaceListViewModelType {
loadData()
}
@objc private func counterDidUpdateNotificationCount(notification: Notification) {
loadData()
}
private func loadData() {
guard let session = self.userSessionsService.mainUserSession?.matrixSession else {
return