-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix issue on timeline bubbles not showing proper content after decrypt #7397
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,10 +26,21 @@ @interface MXKRoomDataSourceManager() | |||||
*/ | ||||||
NSMutableDictionary *roomDataSources; | ||||||
|
||||||
/** | ||||||
The list of rooms with a "late decryption" event. Causing bubbles issues | ||||||
Each element is a room ID. | ||||||
*/ | ||||||
NSMutableSet *roomDataSourcesToDestroy; | ||||||
|
||||||
/** | ||||||
Observe UIApplicationDidReceiveMemoryWarningNotification to dispose of any resources that can be recreated. | ||||||
*/ | ||||||
id UIApplicationDidReceiveMemoryWarningNotificationObserver; | ||||||
|
||||||
/** | ||||||
Observe kMXEventDidDecryptNotification to get late decrypted events. | ||||||
*/ | ||||||
id mxEventDidDecryptNotificationObserver; | ||||||
} | ||||||
|
||||||
@end | ||||||
|
@@ -119,6 +130,7 @@ - (instancetype)initWithMatrixSession:(MXSession *)matrixSession | |||||
{ | ||||||
mxSession = matrixSession; | ||||||
roomDataSources = [NSMutableDictionary dictionary]; | ||||||
roomDataSourcesToDestroy = [NSMutableSet set]; | ||||||
_releasePolicy = MXKRoomDataSourceManagerReleasePolicyNeverRelease; | ||||||
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didMXSessionDidLeaveRoom:) name:kMXSessionDidLeaveRoomNotification object:nil]; | ||||||
|
@@ -138,6 +150,12 @@ - (instancetype)initWithMatrixSession:(MXSession *)matrixSession | |||||
} | ||||||
|
||||||
}]; | ||||||
|
||||||
// Observe late decrypted events, and store rooms ids in memory | ||||||
mxEventDidDecryptNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXEventDidDecryptNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { | ||||||
MXEvent *decryptedEvent = notif.object; | ||||||
[self->roomDataSourcesToDestroy addObject:decryptedEvent.roomId]; | ||||||
}]; | ||||||
} | ||||||
return self; | ||||||
} | ||||||
|
@@ -156,6 +174,11 @@ - (void)destroy | |||||
[[NSNotificationCenter defaultCenter] removeObserver:UIApplicationDidReceiveMemoryWarningNotificationObserver]; | ||||||
UIApplicationDidReceiveMemoryWarningNotificationObserver = nil; | ||||||
} | ||||||
if (mxEventDidDecryptNotificationObserver) | ||||||
{ | ||||||
[[NSNotificationCenter defaultCenter] removeObserver:mxEventDidDecryptNotificationObserver]; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
mxEventDidDecryptNotificationObserver = nil; | ||||||
} | ||||||
} | ||||||
|
||||||
#pragma mark | ||||||
|
@@ -202,9 +225,19 @@ - (void)roomDataSourceForRoom:(NSString *)roomId create:(BOOL)create onComplete: | |||||
|
||||||
// If not available yet, create the room data source | ||||||
MXKRoomDataSource *roomDataSource = roomDataSources[roomId]; | ||||||
|
||||||
|
||||||
// check if the room's dataSource has events with late decryption issues and destroys it | ||||||
BOOL roomDataSourceToBeDestroyed = [roomDataSourcesToDestroy containsObject:roomId]; | ||||||
|
||||||
if (roomDataSource && roomDataSourceToBeDestroyed && create) { | ||||||
[roomDataSource destroy]; | ||||||
roomDataSources[roomId] = nil; | ||||||
Comment on lines
+233
to
+234
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this should be reusing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So basically I found that the best spot to do it is before opening a room. Calling it on closing it won't cover a case when you receive the key once closed. |
||||||
roomDataSource = nil; | ||||||
} | ||||||
|
||||||
if (!roomDataSource && create && roomId) | ||||||
{ | ||||||
[roomDataSourcesToDestroy removeObject:roomId]; | ||||||
[_roomDataSourceClass loadRoomDataSourceWithRoomId:roomId threadId:nil andMatrixSession:mxSession onComplete:^(id roomDataSource) { | ||||||
[self addRoomDataSource:roomDataSource]; | ||||||
onComplete(roomDataSource); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fix issue on timeline's bubbles not showing proper content after decrypt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: dot notation should work on static vars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to remain consistent with similar denotation in the same file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't care much about that.
Writing more readable code is better to me.
I'll leave this up to you in the end. ;)