Skip to content

Commit

Permalink
Fix thread root deletion, fixes element-hq/element-ios#5441
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailgulek committed Jan 27, 2022
1 parent 1fe3312 commit 793c210
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
15 changes: 13 additions & 2 deletions MatrixSDK/Data/MXEventListener.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,20 @@ - (void)notify:(MXEvent*)event direction:(MXTimelineDirection)direction andCusto
BOOL match = NO;
if (_eventTypes)
{
if (NSNotFound != [_eventTypes indexOfObject:event.type])
if (event.type)
{
match = YES;
if (NSNotFound != [_eventTypes indexOfObject:event.type])
{
match = YES;
}
}
else if (event.wireType)
{
// no event type, this is probably a redacted event
if (NSNotFound != [_eventTypes indexOfObject:event.wireType])
{
match = YES;
}
}
}
else
Expand Down
1 change: 1 addition & 0 deletions MatrixSDK/JSONModels/MXEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ + (id)modelFromJSON:(NSDictionary *)JSONDictionary
*/
- (void)finalise
{
_wireEventType = [MXTools eventType:_wireType];
if (MXEventTypePresence == _wireEventType)
{
// Workaround: Presence events provided by the home server do not contain userId
Expand Down
13 changes: 12 additions & 1 deletion MatrixSDK/Threads/MXThreadingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public class MXThreadingService: NSObject {
}
handled = thread.addEvent(event)
saveThread(thread)
NotificationCenter.default.post(name: Self.newThreadCreated, object: thread, userInfo: nil)
DispatchQueue.main.async {
NotificationCenter.default.post(name: Self.newThreadCreated, object: thread, userInfo: nil)
}
}
notifyDidUpdateThreads()
return handled
Expand All @@ -104,6 +106,15 @@ public class MXThreadingService: NSObject {
notifyDidUpdateThreads()
return handled
}
} else if event.eventType == .roomRedaction && direction == .forwards {
if let redactedEventId = event.redacts,
let thread = thread(withId: redactedEventId),
let newEvent = session.store?.event(withEventId: redactedEventId,
inRoom: event.roomId) {
let handled = thread.replaceEvent(withId: redactedEventId, with: newEvent)
notifyDidUpdateThreads()
return handled
}
}
return false
}
Expand Down

0 comments on commit 793c210

Please sign in to comment.