mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Merge pull request #4961 from vector-im/gil/4898_fix_performance_issues_with_spaces
Fix performance issues with Spaces on very large accounts #4898
This commit is contained in:
commit
5486d8ed7f
5 changed files with 20 additions and 5 deletions
|
@ -80,7 +80,7 @@ class SpaceDetailViewModel: SpaceDetailViewModelType {
|
|||
self.update(viewState: .loaded(parameters))
|
||||
|
||||
self.update(viewState: .loading)
|
||||
space.room.state { state in
|
||||
space.room?.state { state in
|
||||
let joinRule = state?.joinRule
|
||||
let membersCount = summary.membersCount.members
|
||||
|
||||
|
|
|
@ -54,6 +54,8 @@ final class SpaceListViewModel: SpaceListViewModelType {
|
|||
|
||||
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)
|
||||
|
||||
}
|
||||
|
||||
deinit {
|
||||
|
@ -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
|
||||
|
|
|
@ -76,12 +76,12 @@ class SpaceMenuViewModel: SpaceMenuViewModelType {
|
|||
}
|
||||
|
||||
private func leaveSpace() {
|
||||
guard let space = self.session.spaceService.getSpace(withId: self.spaceId), let displayName = space.summary?.displayname else {
|
||||
guard let room = self.session.room(withRoomId: self.spaceId), let displayName = room.summary?.displayname else {
|
||||
return
|
||||
}
|
||||
|
||||
var isAdmin = false
|
||||
if let roomState = space.room.dangerousSyncState, let powerLevels = roomState.powerLevels {
|
||||
if let roomState = room.dangerousSyncState, let powerLevels = roomState.powerLevels {
|
||||
let powerLevel = powerLevels.powerLevelOfUser(withUserID: self.session.myUserId)
|
||||
let roomPowerLevel = RoomPowerLevelHelper.roomPowerLevel(from: powerLevel)
|
||||
isAdmin = roomPowerLevel == .admin
|
||||
|
@ -156,7 +156,7 @@ class SpaceMenuViewModel: SpaceMenuViewModelType {
|
|||
}
|
||||
|
||||
private func leaveSpace(_ space: MXSpace) {
|
||||
space.room.leave(completion: { [weak self] response in
|
||||
space.room?.leave(completion: { [weak self] response in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
|
||||
// Custom title view of the navigation bar
|
||||
MainTitleView *titleView;
|
||||
|
||||
id spaceNotificationCounterDidUpdateNotificationCountObserver;
|
||||
}
|
||||
|
||||
@property(nonatomic,getter=isHidden) BOOL hidden;
|
||||
|
@ -122,7 +124,7 @@
|
|||
childViewControllers = [NSMutableArray array];
|
||||
|
||||
MXWeakify(self);
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:MXSpaceService.didBuildSpaceGraph object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
|
||||
spaceNotificationCounterDidUpdateNotificationCountObserver = [[NSNotificationCenter defaultCenter] addObserverForName:MXSpaceNotificationCounter.didUpdateNotificationCount object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self updateSideMenuNotifcationIcon];
|
||||
}];
|
||||
|
@ -272,6 +274,12 @@
|
|||
kThemeServiceDidChangeThemeNotificationObserver = nil;
|
||||
}
|
||||
|
||||
if (spaceNotificationCounterDidUpdateNotificationCountObserver)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:spaceNotificationCounterDidUpdateNotificationCountObserver];
|
||||
spaceNotificationCounterDidUpdateNotificationCountObserver = nil;
|
||||
}
|
||||
|
||||
childViewControllers = nil;
|
||||
}
|
||||
|
||||
|
|
1
changelog.d/4898.bugfix
Normal file
1
changelog.d/4898.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
MasterTabBarController: Listen to `MXSpaceNotificationCounter` to update the notification badge
|
Loading…
Reference in a new issue