Merge pull request #608 from vector-im/mention_only

Bug Fix changing notif setting from swipe menu should change the room apparence in the list 
#525

Messages: Regular notifications should be ignored when the room is in mentions only mode.
This commit is contained in:
giomfo 2016-10-14 16:20:31 +02:00 committed by GitHub
commit 961b8977b8
2 changed files with 34 additions and 0 deletions

View file

@ -22,6 +22,8 @@
#import "MXKRoomBubbleTableViewCell+Vector.h"
#import "AvatarGenerator.h"
#import "MXRoom+Vector.h"
@implementation RoomDataSource
- (instancetype)initWithRoomId:(NSString *)roomId andMatrixSession:(MXSession *)matrixSession
@ -51,6 +53,18 @@
return self;
}
// Ignore regular notification count if the room is in 'mentions only" mode
- (NSUInteger)notificationCount
{
if (self.room.isMentionsOnly)
{
// Only the highlighted missed messages are counted
return super.highlightCount;
}
return super.notificationCount;
}
- (void)didReceiveReceiptEvent:(MXEvent *)receiptEvent roomState:(MXRoomState *)roomState
{
// Override this callback to force rendering of each cell with read receipts information.

View file

@ -58,6 +58,9 @@
// Observe kAppDelegateDidTapStatusBarNotification to handle tap on clock status bar.
id kAppDelegateDidTapStatusBarNotificationObserver;
// Observe kMXNotificationCenterDidUpdateRules to update missed messages counts.
id kMXNotificationCenterDidUpdateRulesObserver;
}
@end
@ -165,6 +168,17 @@
[self scrollToTop:YES];
}];
// Observe kMXNotificationCenterDidUpdateRules to refresh missed messages counts
kMXNotificationCenterDidUpdateRulesObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXNotificationCenterDidUpdateRules object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
// Do not refresh if there is a pending recent drag and drop
if (!movingCellPath)
{
[self refreshRecentsTable];
}
}];
}
}
@ -180,6 +194,12 @@
[[NSNotificationCenter defaultCenter] removeObserver:kAppDelegateDidTapStatusBarNotificationObserver];
kAppDelegateDidTapStatusBarNotificationObserver = nil;
}
if (kMXNotificationCenterDidUpdateRulesObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:kMXNotificationCenterDidUpdateRulesObserver];
kMXNotificationCenterDidUpdateRulesObserver = nil;
}
}
- (void)viewDidAppear:(BOOL)animated