Skip to content

Commit 629e7b7

Browse files
committed
Activer l'affichage en thread (#878)
1 parent da37f78 commit 629e7b7

16 files changed

+470
-487
lines changed

Riot/Managers/PushNotification/PushNotificationService.m

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -487,28 +487,28 @@ - (void)handleNotificationInlineReplyForRoomId:(NSString*)roomId
487487
// initialize data source for a thread or a room
488488
__block MXKRoomDataSource *dataSource;
489489
dispatch_group_t dispatchGroupDataSource = dispatch_group_create();
490-
// Tchap: Disable Threads
491-
// if (RiotSettings.shared.enableThreads && threadId)
492-
// {
493-
// dispatch_group_enter(dispatchGroupDataSource);
494-
// [ThreadDataSource loadRoomDataSourceWithRoomId:roomId
495-
// initialEventId:nil
496-
// threadId:threadId
497-
// andMatrixSession:mxSession
498-
// onComplete:^(MXKRoomDataSource *threadDataSource) {
499-
// dataSource = threadDataSource;
500-
// dispatch_group_leave(dispatchGroupDataSource);
501-
// }];
502-
// }
503-
// else
504-
// {
490+
491+
if (RiotSettings.shared.enableThreads && threadId)
492+
{
493+
dispatch_group_enter(dispatchGroupDataSource);
494+
[ThreadDataSource loadRoomDataSourceWithRoomId:roomId
495+
initialEventId:nil
496+
threadId:threadId
497+
andMatrixSession:mxSession
498+
onComplete:^(MXKRoomDataSource *threadDataSource) {
499+
dataSource = threadDataSource;
500+
dispatch_group_leave(dispatchGroupDataSource);
501+
}];
502+
}
503+
else
504+
{
505505
dispatch_group_enter(dispatchGroupDataSource);
506506
MXKRoomDataSourceManager *manager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:mxSession];
507507
[manager roomDataSourceForRoom:roomId create:YES onComplete:^(MXKRoomDataSource *roomDataSource) {
508508
dataSource = roomDataSource;
509509
dispatch_group_leave(dispatchGroupDataSource);
510510
}];
511-
// }
511+
}
512512

513513
dispatch_group_notify(dispatchGroupDataSource, dispatch_get_main_queue(), ^{
514514
if (responseText != nil && responseText.length != 0)

Riot/Modules/Room/CellData/RoomBubbleCellData.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,9 @@ - (CGFloat)threadSummaryViewHeightForEventId:(NSString*)eventId
838838
// component is not a thread root
839839
return 0;
840840
}
841-
return 0; // Threads are disabled in Tchap
842-
// return PlainRoomCellLayoutConstants.threadSummaryViewTopMargin +
843-
// [ThreadSummaryView contentViewHeightForThread:component.thread fitting:self.maxTextViewWidth];
841+
// return 0; // Threads are disabled in Tchap
842+
return PlainRoomCellLayoutConstants.threadSummaryViewTopMargin +
843+
[ThreadSummaryView contentViewHeightForThread:component.thread fitting:self.maxTextViewWidth];
844844
}
845845

846846
- (CGFloat)fromAThreadViewHeightForEventId:(NSString*)eventId
@@ -866,9 +866,9 @@ - (CGFloat)fromAThreadViewHeightForEventId:(NSString*)eventId
866866
// event is not in a thread
867867
return 0;
868868
}
869-
return 0; // Threads are disabled in Tchap
870-
// return PlainRoomCellLayoutConstants.fromAThreadViewTopMargin +
871-
// [FromAThreadView contentViewHeightForEvent:component.event fitting:self.maxTextViewWidth];
869+
// return 0; // Threads are disabled in Tchap
870+
return PlainRoomCellLayoutConstants.fromAThreadViewTopMargin +
871+
[FromAThreadView contentViewHeightForEvent:component.event fitting:self.maxTextViewWidth];
872872
}
873873

874874
- (CGFloat)urlPreviewHeightForEventId:(NSString*)eventId

Riot/Modules/Room/DataSources/RoomDataSource.m

Lines changed: 64 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -266,47 +266,46 @@ - (void)fetchEncryptionTrustedLevel
266266

267267
- (BOOL)shouldQueueEventForProcessing:(MXEvent *)event roomState:(MXRoomState *)roomState direction:(MXTimelineDirection)direction
268268
{
269-
// Tchap: Disable Threads
270-
// if (self.threadId)
271-
// {
272-
// // if in a thread, ignore non-root event or events from other threads
273-
// if (![event.eventId isEqualToString:self.threadId] && ![event.threadId isEqualToString:self.threadId])
274-
// {
275-
// // Ignore the event
276-
// return NO;
277-
// }
278-
// // also ignore events related to un-threaded or events from other threads
279-
// if (!event.isInThread && event.relatesTo.eventId)
280-
// {
281-
// MXEvent *relatedEvent = [self.mxSession.store eventWithEventId:event.relatesTo.eventId
282-
// inRoom:event.roomId];
283-
// if (![relatedEvent.threadId isEqualToString:self.threadId])
284-
// {
285-
// // ignore the event
286-
// return NO;
287-
// }
288-
// }
289-
// }
290-
// else if (RiotSettings.shared.enableThreads)
291-
// {
292-
// // if not in a thread, ignore all threaded events
293-
// if (event.isInThread)
294-
// {
295-
// // ignore the event
296-
// return NO;
297-
// }
298-
// // also ignore events related to threaded events
299-
// if (event.relatesTo.eventId)
300-
// {
301-
// MXEvent *relatedEvent = [self.mxSession.store eventWithEventId:event.relatesTo.eventId
302-
// inRoom:event.roomId];
303-
// if (relatedEvent.isInThread)
304-
// {
305-
// // ignore the event
306-
// return NO;
307-
// }
308-
// }
309-
// }
269+
if (self.threadId)
270+
{
271+
// if in a thread, ignore non-root event or events from other threads
272+
if (![event.eventId isEqualToString:self.threadId] && ![event.threadId isEqualToString:self.threadId])
273+
{
274+
// Ignore the event
275+
return NO;
276+
}
277+
// also ignore events related to un-threaded or events from other threads
278+
if (!event.isInThread && event.relatesTo.eventId)
279+
{
280+
MXEvent *relatedEvent = [self.mxSession.store eventWithEventId:event.relatesTo.eventId
281+
inRoom:event.roomId];
282+
if (![relatedEvent.threadId isEqualToString:self.threadId])
283+
{
284+
// ignore the event
285+
return NO;
286+
}
287+
}
288+
}
289+
else if (RiotSettings.shared.enableThreads)
290+
{
291+
// if not in a thread, ignore all threaded events
292+
if (event.isInThread)
293+
{
294+
// ignore the event
295+
return NO;
296+
}
297+
// also ignore events related to threaded events
298+
if (event.relatesTo.eventId)
299+
{
300+
MXEvent *relatedEvent = [self.mxSession.store eventWithEventId:event.relatesTo.eventId
301+
inRoom:event.roomId];
302+
if (relatedEvent.isInThread)
303+
{
304+
// ignore the event
305+
return NO;
306+
}
307+
}
308+
}
310309

311310
return [super shouldQueueEventForProcessing:event roomState:roomState direction:direction];
312311
}
@@ -478,26 +477,25 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
478477
cellData:cellData contentViewPositionY:bottomPositionY upperDecorationView:urlPreviewView];
479478
}
480479

481-
// Tchap: Disable Threads
482-
// ThreadSummaryView *threadSummaryView;
483-
//
484-
// // display thread summary view if the component has a thread in the room timeline
485-
// if (RiotSettings.shared.enableThreads && component.thread && !self.threadId)
486-
// {
487-
// threadSummaryView = [[ThreadSummaryView alloc] initWithThread:component.thread
488-
// session:self.mxSession];
489-
// threadSummaryView.delegate = self;
490-
// threadSummaryView.tag = index;
491-
//
492-
// [temporaryViews addObject:threadSummaryView];
493-
// UIView *upperDecorationView = reactionsView ?: urlPreviewView;
494-
//
495-
// [cellDecorator addThreadSummaryView:threadSummaryView
496-
// toCell:bubbleCell
497-
// cellData:cellData
498-
// contentViewPositionY:bottomPositionY
499-
// upperDecorationView:upperDecorationView];
500-
// }
480+
ThreadSummaryView *threadSummaryView;
481+
482+
// display thread summary view if the component has a thread in the room timeline
483+
if (RiotSettings.shared.enableThreads && component.thread && !self.threadId)
484+
{
485+
threadSummaryView = [[ThreadSummaryView alloc] initWithThread:component.thread
486+
session:self.mxSession];
487+
threadSummaryView.delegate = self;
488+
threadSummaryView.tag = index;
489+
490+
[temporaryViews addObject:threadSummaryView];
491+
UIView *upperDecorationView = reactionsView ?: urlPreviewView;
492+
493+
[cellDecorator addThreadSummaryView:threadSummaryView
494+
toCell:bubbleCell
495+
cellData:cellData
496+
contentViewPositionY:bottomPositionY
497+
upperDecorationView:upperDecorationView];
498+
}
501499

502500
MXKReceiptSendersContainer* avatarsContainer;
503501

@@ -1213,12 +1211,11 @@ - (void)didCloseURLPreviewView:(URLPreviewView *)previewView for:(NSString *)eve
12131211

12141212
#pragma mark - ThreadSummaryViewDelegate
12151213

1216-
// Tchap: Disable Threads
1217-
//- (void)threadSummaryViewTapped:(ThreadSummaryView *)summaryView
1218-
//{
1219-
// [self.roomDataSourceDelegate roomDataSource:self
1220-
// didTapThread:summaryView.thread];
1221-
//}
1214+
- (void)threadSummaryViewTapped:(ThreadSummaryView *)summaryView
1215+
{
1216+
[self.roomDataSourceDelegate roomDataSource:self
1217+
didTapThread:summaryView.thread];
1218+
}
12221219

12231220
#pragma mark - Location sharing
12241221

Riot/Modules/Room/RoomCoordinator.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,12 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
8080
self.selectedEventId = parameters.eventId
8181
self.userIndicatorStore = UserIndicatorStore(presenter: parameters.userIndicatorPresenter)
8282

83-
// Tchap: Disable Threads
84-
// if let threadId = parameters.threadId {
85-
// self.roomViewController = ThreadViewController.instantiate(withThreadId: threadId,
86-
// configuration: parameters.displayConfiguration)
87-
// } else {
83+
if let threadId = parameters.threadId {
84+
self.roomViewController = ThreadViewController.instantiate(withThreadId: threadId,
85+
configuration: parameters.displayConfiguration)
86+
} else {
8887
self.roomViewController = RoomViewController.instantiate(with: parameters.displayConfiguration)
89-
// }
88+
}
9089
self.roomViewController.userIndicatorStore = userIndicatorStore
9190
self.roomViewController.showSettingsInitially = parameters.showSettingsInitially
9291

Riot/Modules/Room/RoomViewController.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131
@class UniversalLinkParameters;
3232
@protocol RoomViewControllerDelegate;
3333
@class RoomDisplayConfiguration;
34-
// Tchap: Disable Threads
34+
@class ThreadsCoordinatorBridgePresenter;
3535
// Tchap: Disable Live location sharing
36-
//@class ThreadsCoordinatorBridgePresenter;
3736
//@class LiveLocationSharingBannerView;
3837
@class VoiceBroadcastService;
3938
@class ComposerLinkActionBridgePresenter;
@@ -355,8 +354,7 @@ didRequestEditForPollWithStartEvent:(MXEvent *)startEvent;
355354
- (void)roomViewControllerDidTapLiveLocationSharingBanner:(RoomViewController *)roomViewController;
356355

357356
/// Request a threads coordinator for a given threadId, used to open a thread from within a room.
358-
// Tchap: Disable Threads
359-
//- (nullable ThreadsCoordinatorBridgePresenter *)threadsCoordinatorForRoomViewController:(RoomViewController *)roomViewController threadId:(nullable NSString *)threadId;
357+
(nullable ThreadsCoordinatorBridgePresenter *)threadsCoordinatorForRoomViewController:(RoomViewController *)roomViewController threadId:(nullable NSString *)threadId;
360358

361359
@end
362360

0 commit comments

Comments
 (0)