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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Btchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,33 @@ final class BuildSettings: NSObject {

static let allowBackgroundAudioMessagePlayback: Bool = true

// Tchap: Feature activation by Instance
static let tchapFeatureAnyFeature = "*" // To allow any feature for some instances
static let tchapFeatureAnyHomeServer = "*" // To allow a feature for any instance
// tchapFeatureAnyFeature : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ tchapFeatureAnyHomeServer ] to allow a feature to any instance
static let tchapFeatureNotificationByEmail = "tchapFeatureNotificationByEmail"
static let tchapFeatureVoiceOverIP = "tchapFeatureVoiceOverIP"
static let tchapFeatureVideoOverIP = "tchapFeatureVideoOverIP" // Tchap: in pre-prod, allow any feature to any instance.
static let tchapFeatureThreads = "tchapFeatureThreads"
static var tchapFeaturesAllowedHomeServersForFeature: [String: [String]] = [
tchapFeatureNotificationByEmail: [
"agent.dinum.tchap.gouv.fr"
],
// No activation of VoIP calls actually in Tchap Production.
// tchapFeatureVoiceOverIP: [
// "agent.dinum.tchap.gouv.fr"
// ],
// No activation of video calls actually in Tchap Production.
// tchapFeatureVideoOverIP: [
// "agent.dinum.tchap.gouv.fr"
// ],
// No activation of Threads actually in Tchap Production.
// tchapFeatureThreads: [
// "agent.dinum.tchap.gouv.fr"
// ]
]

// MARK: - Side Menu
static let enableSideMenu: Bool = true && !newAppLayoutEnabled
static let sideMenuShowInviteFriends: Bool = true
Expand Down
16 changes: 16 additions & 0 deletions DevTchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,22 @@ final class BuildSettings: NSObject {

static let allowBackgroundAudioMessagePlayback: Bool = true

// Tchap: Feature activation by Instance
static let tchapFeatureAnyFeature = "*" // To allow any feature for some instances
static let tchapFeatureAnyHomeServer = "*" // To allow a feature for any instance
// tchapFeatureAnyFeature : [ <instance> ] to allow any feature for an instance
// "<feature ID>" : [ tchapFeatureAnyHomeServer ] to allow a feature to any instance
static let tchapFeatureNotificationByEmail = "tchapFeatureNotificationByEmail"
static let tchapFeatureVoiceOverIP = "tchapFeatureVoiceOverIP"
static let tchapFeatureVideoOverIP = "tchapFeatureVideoOverIP" // Tchap: in Dev, allow any feature to any instance.
static let tchapFeatureThreads = "tchapFeatureThreads"
static var tchapFeaturesAllowedHomeServersForFeature: [String: [String]] = [
tchapFeatureNotificationByEmail: [ tchapFeatureAnyHomeServer ],
tchapFeatureVoiceOverIP: [ tchapFeatureAnyHomeServer ],
tchapFeatureVideoOverIP: [ tchapFeatureAnyHomeServer ],
tchapFeatureThreads: [ tchapFeatureAnyHomeServer ]
]

// MARK: - Side Menu
static let enableSideMenu: Bool = true && !newAppLayoutEnabled
static let sideMenuShowInviteFriends: Bool = true
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: bdd98ddb1a6b2f5d45b1fc00ccfbf2dbaeeb0ff0

COCOAPODS: 1.11.3
COCOAPODS: 1.14.3
31 changes: 15 additions & 16 deletions Riot/Managers/PushNotification/PushNotificationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -487,28 +487,27 @@ - (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
15 changes: 14 additions & 1 deletion Riot/Managers/Settings/RiotSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,21 @@ final class RiotSettings: NSObject {
var enableRingingForGroupCalls

/// Indicates if threads enabled in the timeline.
// Tchap: hijack property to allow thread only for DINUM agents
// @UserDefault(key: "enableThreads", defaultValue: false, storage: defaults)
// var enableThreads
@UserDefault(key: "enableThreads", defaultValue: false, storage: defaults)
var enableThreads
var _enableThreads
var enableThreads: Bool {
get {
// only allow true for DINUM agent
let account = MXKAccountManager.shared().activeAccounts.first
return (account?.isFeatureActivated(BuildSettings.tchapFeatureThreads) ?? false) && _enableThreads
}
set {
_enableThreads = newValue
}
}

/// Indicates if threads should be forced enabled in the timeline.
@UserDefault(key: "forceThreadsEnabled", defaultValue: true, storage: defaults)
Expand Down
9 changes: 8 additions & 1 deletion Riot/Modules/MatrixKit/Models/Account/MXKAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ typedef BOOL (^MXKAccountOnCertificateChange)(MXKAccount *mxAccount, NSData *cer

/**
The account user's presence (`MXPresenceUnknown` by default, available if matrix session `mxSession` is opened).
The notification `kMXKAccountUserInfoDidChangeNotification` is posted in case of change of this property.
The notification `kMXKAccountUserInfoDidChangeNotification` is posted in case of change of this property.
*/
@property (nonatomic, readonly) MXPresence userPresence;

Expand Down Expand Up @@ -364,4 +364,11 @@ typedef BOOL (^MXKAccountOnCertificateChange)(MXKAccount *mxAccount, NSData *cer
Handle unauthenticated errors from the server triggering hard/soft logouts as appropriate.
*/
- (void)handleUnauthenticatedWithError:(MXError *)error isSoftLogout:(BOOL)isSoftLogout isRefreshTokenAuth:(BOOL)isRefreshTokenAuth andCompletion:(void (^)(void))completion;


// Tchap: helpers
#pragma mark - Tchap Helpers

- (BOOL)belongsToHomeServer:(nonnull NSString *)homeServer;

@end
7 changes: 7 additions & 0 deletions Riot/Modules/MatrixKit/Models/Account/MXKAccount.m
Original file line number Diff line number Diff line change
Expand Up @@ -2295,4 +2295,11 @@ - (void)setPreferredSyncPresence:(MXPresence)preferredSyncPresence
[[MXKAccountManager sharedManager] saveAccounts];
}

// Tchap: helpers
#pragma mark - Tchap Helpers

- (BOOL)belongsToHomeServer:(nonnull NSString *)homeServer {
return [self.identityServerURL isEqualToString:[BuildSettings.serverUrlPrefix stringByAppendingString:homeServer]];
}

@end
11 changes: 5 additions & 6 deletions Riot/Modules/Room/CellData/RoomBubbleCellData.m
Original file line number Diff line number Diff line change
Expand Up @@ -838,9 +838,8 @@ - (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 PlainRoomCellLayoutConstants.threadSummaryViewTopMargin +
[ThreadSummaryView contentViewHeightForThread:component.thread fitting:self.maxTextViewWidth];
}

- (CGFloat)fromAThreadViewHeightForEventId:(NSString*)eventId
Expand All @@ -866,9 +865,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