Skip to content
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

Activer l'affichage en thread (#878) #879

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open
32 changes: 16 additions & 16 deletions Riot/Managers/PushNotification/PushNotificationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -487,28 +487,28 @@ - (void)handleNotificationInlineReplyForRoomId:(NSString*)roomId
// initialize data source for a thread or a room
__block MXKRoomDataSource *dataSource;
dispatch_group_t dispatchGroupDataSource = dispatch_group_create();
// Tchap: Disable Threads
// if (RiotSettings.shared.enableThreads && threadId)
// {
// dispatch_group_enter(dispatchGroupDataSource);
// [ThreadDataSource loadRoomDataSourceWithRoomId:roomId
// initialEventId:nil
// threadId:threadId
// andMatrixSession:mxSession
// onComplete:^(MXKRoomDataSource *threadDataSource) {
// dataSource = threadDataSource;
// dispatch_group_leave(dispatchGroupDataSource);
// }];
// }
// else
// {

if (RiotSettings.shared.enableThreads && threadId)
{
dispatch_group_enter(dispatchGroupDataSource);
[ThreadDataSource loadRoomDataSourceWithRoomId:roomId
initialEventId:nil
threadId:threadId
andMatrixSession:mxSession
onComplete:^(MXKRoomDataSource *threadDataSource) {
dataSource = threadDataSource;
dispatch_group_leave(dispatchGroupDataSource);
}];
}
else
{
dispatch_group_enter(dispatchGroupDataSource);
MXKRoomDataSourceManager *manager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:mxSession];
[manager roomDataSourceForRoom:roomId create:YES onComplete:^(MXKRoomDataSource *roomDataSource) {
dataSource = roomDataSource;
dispatch_group_leave(dispatchGroupDataSource);
}];
// }
}

dispatch_group_notify(dispatchGroupDataSource, dispatch_get_main_queue(), ^{
if (responseText != nil && responseText.length != 0)
Expand Down
12 changes: 6 additions & 6 deletions Riot/Modules/Room/CellData/RoomBubbleCellData.m
Original file line number Diff line number Diff line change
Expand Up @@ -838,9 +838,9 @@ - (CGFloat)threadSummaryViewHeightForEventId:(NSString*)eventId
// component is not a thread root
return 0;
}
return 0; // Threads are disabled in Tchap
// return PlainRoomCellLayoutConstants.threadSummaryViewTopMargin +
// [ThreadSummaryView contentViewHeightForThread:component.thread fitting:self.maxTextViewWidth];
// return 0; // Threads are disabled in Tchap
return PlainRoomCellLayoutConstants.threadSummaryViewTopMargin +
[ThreadSummaryView contentViewHeightForThread:component.thread fitting:self.maxTextViewWidth];
}

- (CGFloat)fromAThreadViewHeightForEventId:(NSString*)eventId
Expand All @@ -866,9 +866,9 @@ - (CGFloat)fromAThreadViewHeightForEventId:(NSString*)eventId
// event is not in a thread
return 0;
}
return 0; // Threads are disabled in Tchap
// return PlainRoomCellLayoutConstants.fromAThreadViewTopMargin +
// [FromAThreadView contentViewHeightForEvent:component.event fitting:self.maxTextViewWidth];
// return 0; // Threads are disabled in Tchap
return PlainRoomCellLayoutConstants.fromAThreadViewTopMargin +
[FromAThreadView contentViewHeightForEvent:component.event fitting:self.maxTextViewWidth];
}

- (CGFloat)urlPreviewHeightForEventId:(NSString*)eventId
Expand Down
131 changes: 64 additions & 67 deletions Riot/Modules/Room/DataSources/RoomDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -266,47 +266,46 @@ - (void)fetchEncryptionTrustedLevel

- (BOOL)shouldQueueEventForProcessing:(MXEvent *)event roomState:(MXRoomState *)roomState direction:(MXTimelineDirection)direction
{
// Tchap: Disable Threads
// if (self.threadId)
// {
// // if in a thread, ignore non-root event or events from other threads
// if (![event.eventId isEqualToString:self.threadId] && ![event.threadId isEqualToString:self.threadId])
// {
// // Ignore the event
// return NO;
// }
// // also ignore events related to un-threaded or events from other threads
// if (!event.isInThread && event.relatesTo.eventId)
// {
// MXEvent *relatedEvent = [self.mxSession.store eventWithEventId:event.relatesTo.eventId
// inRoom:event.roomId];
// if (![relatedEvent.threadId isEqualToString:self.threadId])
// {
// // ignore the event
// return NO;
// }
// }
// }
// else if (RiotSettings.shared.enableThreads)
// {
// // if not in a thread, ignore all threaded events
// if (event.isInThread)
// {
// // ignore the event
// return NO;
// }
// // also ignore events related to threaded events
// if (event.relatesTo.eventId)
// {
// MXEvent *relatedEvent = [self.mxSession.store eventWithEventId:event.relatesTo.eventId
// inRoom:event.roomId];
// if (relatedEvent.isInThread)
// {
// // ignore the event
// return NO;
// }
// }
// }
if (self.threadId)
{
// if in a thread, ignore non-root event or events from other threads
if (![event.eventId isEqualToString:self.threadId] && ![event.threadId isEqualToString:self.threadId])
{
// Ignore the event
return NO;
}
// also ignore events related to un-threaded or events from other threads
if (!event.isInThread && event.relatesTo.eventId)
{
MXEvent *relatedEvent = [self.mxSession.store eventWithEventId:event.relatesTo.eventId
inRoom:event.roomId];
if (![relatedEvent.threadId isEqualToString:self.threadId])
{
// ignore the event
return NO;
}
}
}
else if (RiotSettings.shared.enableThreads)
{
// if not in a thread, ignore all threaded events
if (event.isInThread)
{
// ignore the event
return NO;
}
// also ignore events related to threaded events
if (event.relatesTo.eventId)
{
MXEvent *relatedEvent = [self.mxSession.store eventWithEventId:event.relatesTo.eventId
inRoom:event.roomId];
if (relatedEvent.isInThread)
{
// ignore the event
return NO;
}
}
}

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

// Tchap: Disable Threads
// ThreadSummaryView *threadSummaryView;
//
// // display thread summary view if the component has a thread in the room timeline
// if (RiotSettings.shared.enableThreads && component.thread && !self.threadId)
// {
// threadSummaryView = [[ThreadSummaryView alloc] initWithThread:component.thread
// session:self.mxSession];
// threadSummaryView.delegate = self;
// threadSummaryView.tag = index;
//
// [temporaryViews addObject:threadSummaryView];
// UIView *upperDecorationView = reactionsView ?: urlPreviewView;
//
// [cellDecorator addThreadSummaryView:threadSummaryView
// toCell:bubbleCell
// cellData:cellData
// contentViewPositionY:bottomPositionY
// upperDecorationView:upperDecorationView];
// }
ThreadSummaryView *threadSummaryView;

// display thread summary view if the component has a thread in the room timeline
if (RiotSettings.shared.enableThreads && component.thread && !self.threadId)
{
threadSummaryView = [[ThreadSummaryView alloc] initWithThread:component.thread
session:self.mxSession];
threadSummaryView.delegate = self;
threadSummaryView.tag = index;

[temporaryViews addObject:threadSummaryView];
UIView *upperDecorationView = reactionsView ?: urlPreviewView;

[cellDecorator addThreadSummaryView:threadSummaryView
toCell:bubbleCell
cellData:cellData
contentViewPositionY:bottomPositionY
upperDecorationView:upperDecorationView];
}

MXKReceiptSendersContainer* avatarsContainer;

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

#pragma mark - ThreadSummaryViewDelegate

// Tchap: Disable Threads
//- (void)threadSummaryViewTapped:(ThreadSummaryView *)summaryView
//{
// [self.roomDataSourceDelegate roomDataSource:self
// didTapThread:summaryView.thread];
//}
- (void)threadSummaryViewTapped:(ThreadSummaryView *)summaryView
{
[self.roomDataSourceDelegate roomDataSource:self
didTapThread:summaryView.thread];
}

#pragma mark - Location sharing

Expand Down
11 changes: 5 additions & 6 deletions Riot/Modules/Room/RoomCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,12 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
self.selectedEventId = parameters.eventId
self.userIndicatorStore = UserIndicatorStore(presenter: parameters.userIndicatorPresenter)

// Tchap: Disable Threads
// if let threadId = parameters.threadId {
// self.roomViewController = ThreadViewController.instantiate(withThreadId: threadId,
// configuration: parameters.displayConfiguration)
// } else {
if let threadId = parameters.threadId {
self.roomViewController = ThreadViewController.instantiate(withThreadId: threadId,
configuration: parameters.displayConfiguration)
} else {
self.roomViewController = RoomViewController.instantiate(with: parameters.displayConfiguration)
// }
}
self.roomViewController.userIndicatorStore = userIndicatorStore
self.roomViewController.showSettingsInitially = parameters.showSettingsInitially

Expand Down
6 changes: 2 additions & 4 deletions Riot/Modules/Room/RoomViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
@class UniversalLinkParameters;
@protocol RoomViewControllerDelegate;
@class RoomDisplayConfiguration;
// Tchap: Disable Threads
@class ThreadsCoordinatorBridgePresenter;
// Tchap: Disable Live location sharing
//@class ThreadsCoordinatorBridgePresenter;
//@class LiveLocationSharingBannerView;
@class VoiceBroadcastService;
@class ComposerLinkActionBridgePresenter;
Expand Down Expand Up @@ -355,8 +354,7 @@ didRequestEditForPollWithStartEvent:(MXEvent *)startEvent;
- (void)roomViewControllerDidTapLiveLocationSharingBanner:(RoomViewController *)roomViewController;

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

@end

Expand Down
Loading
Loading