Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
Redacting membership events should immediately reset the displayname …
Browse files Browse the repository at this point in the history
…& avatar of room members.

element-hq/element-ios#443

Fix Manu's comments (matrix-org/matrix-ios-sdk#118)
  • Loading branch information
giomfo committed Aug 12, 2016
1 parent 1a53111 commit 6c54025
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 47 deletions.
10 changes: 0 additions & 10 deletions MatrixKit/Categories/MXEvent+MatrixKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,6 @@ typedef enum : NSUInteger
*/
- (void)setMxkState:(MXKEventState)mxkState;

/**
Indicates if the event has been redacted
*/
- (BOOL)isRedactedEvent;

/**
Return YES if the event is an emote event
*/
- (BOOL)isEmote;

/**
Return YES if the event contains a media: image, audio, video or file.
*/
Expand Down
18 changes: 0 additions & 18 deletions MatrixKit/Categories/MXEvent+MatrixKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,6 @@ - (void)setMxkState:(MXKEventState)state
objc_setAssociatedObject(self, @selector(state), [NSNumber numberWithUnsignedInteger:state], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (BOOL)isRedactedEvent
{
return (self.redactedBecause != nil);
}

- (BOOL)isEmote
{
if (self.eventType == MXEventTypeRoomMessage)
{
NSString *msgtype = self.content[@"msgtype"];
if ([msgtype isEqualToString:kMXMessageTypeEmote])
{
return YES;
}
}
return NO;
}

- (BOOL)isMediaAttachment
{
if (self.eventType == MXEventTypeRoomMessage)
Expand Down
12 changes: 6 additions & 6 deletions MatrixKit/Controllers/MXKRoomMemberDetailsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ @interface MXKRoomMemberDetailsViewController ()
// Observe left rooms
id leaveRoomNotificationObserver;

// Observe kMXRoomDidFlushMessagesNotification to take into account the updated room members when the room history is flushed.
id roomDidFlushMessagesNotificationObserver;
// Observe kMXRoomDidFlushDataNotification to take into account the updated room members when the room history is flushed.
id roomDidFlushDataNotificationObserver;
}

@end
Expand Down Expand Up @@ -483,7 +483,7 @@ - (void)initObservers
}];

// Observe room history flush (sync with limited timeline, or state event redaction)
roomDidFlushMessagesNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXRoomDidFlushMessagesNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
roomDidFlushDataNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXRoomDidFlushDataNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {

MXRoom *room = notif.object;
if (self.mainSession == room.mxSession && [mxRoom.state.roomId isEqualToString:room.state.roomId])
Expand All @@ -506,10 +506,10 @@ - (void)removeObservers
[[NSNotificationCenter defaultCenter] removeObserver:leaveRoomNotificationObserver];
leaveRoomNotificationObserver = nil;
}
if (roomDidFlushMessagesNotificationObserver)
if (roomDidFlushDataNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushMessagesNotificationObserver];
roomDidFlushMessagesNotificationObserver = nil;
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushDataNotificationObserver];
roomDidFlushDataNotificationObserver = nil;
}

[[NSNotificationCenter defaultCenter] removeObserver:self];
Expand Down
12 changes: 6 additions & 6 deletions MatrixKit/Controllers/MXKRoomSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ @interface MXKRoomSettingsViewController()
// Observe kMXSessionWillLeaveRoomNotification to be notified if the user leaves the current room.
id leaveRoomNotificationObserver;

// Observe kMXRoomDidFlushMessagesNotification to take into account the updated room state when the room history is flushed.
id roomDidFlushMessagesNotificationObserver;
// Observe kMXRoomDidFlushDataNotification to take into account the updated room state when the room history is flushed.
id roomDidFlushDataNotificationObserver;
}
@end

Expand Down Expand Up @@ -72,10 +72,10 @@ - (void)destroy
leaveRoomNotificationObserver = nil;
}

if (roomDidFlushMessagesNotificationObserver)
if (roomDidFlushDataNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushMessagesNotificationObserver];
roomDidFlushMessagesNotificationObserver = nil;
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushDataNotificationObserver];
roomDidFlushDataNotificationObserver = nil;
}

mxRoom = nil;
Expand Down Expand Up @@ -153,7 +153,7 @@ - (void)initWithSession:(MXSession*)mxSession andRoomId:(NSString*)roomId
}];

// Observe room history flush (sync with limited timeline, or state event redaction)
roomDidFlushMessagesNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXRoomDidFlushMessagesNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
roomDidFlushDataNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXRoomDidFlushDataNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {

MXRoom *room = notif.object;
if (self.mainSession == room.mxSession && [self.roomId isEqualToString:room.state.roomId])
Expand Down
12 changes: 6 additions & 6 deletions MatrixKit/Models/Room/MXKRoomDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ Current pagination request (if any)
id NSCurrentLocaleDidChangeNotificationObserver;

/**
Observe kMXRoomDidFlushMessagesNotification to trigger cell change when existing room history has been flushed during server sync.
Observe kMXRoomDidFlushDataNotification to trigger cell change when existing room history has been flushed during server sync.
*/
id roomDidFlushMessagesNotificationObserver;
id roomDidFlushDataNotificationObserver;

/**
Observe kMXRoomDidUpdateUnreadNotification to refresh unread counters.
Expand Down Expand Up @@ -322,10 +322,10 @@ - (void)limitMemoryUsage:(NSInteger)maxBubbleNb

- (void)reset
{
if (roomDidFlushMessagesNotificationObserver)
if (roomDidFlushDataNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushMessagesNotificationObserver];
roomDidFlushMessagesNotificationObserver = nil;
[[NSNotificationCenter defaultCenter] removeObserver:roomDidFlushDataNotificationObserver];
roomDidFlushDataNotificationObserver = nil;
}

if (roomDidUpdateUnreadNotificationObserver)
Expand Down Expand Up @@ -484,7 +484,7 @@ - (void)didMXSessionStateChange
[_timeline resetPagination];

// Observe room history flush (sync with limited timeline, or state event redaction)
roomDidFlushMessagesNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXRoomDidFlushMessagesNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
roomDidFlushDataNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXRoomDidFlushDataNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {

MXRoom *room = notif.object;
if (self.mxSession == room.mxSession && [self.roomId isEqualToString:room.state.roomId])
Expand Down
1 change: 0 additions & 1 deletion MatrixKit/Views/MXKEventDetailsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#import "MXKEventDetailsView.h"

#import "MXEvent+MatrixKit.h"
#import "NSBundle+MatrixKit.h"

#import "MXKConstants.h"
Expand Down

0 comments on commit 6c54025

Please # to comment.