Display opt-in screen if threads disabled

This commit is contained in:
ismailgulek
2022-04-04 16:59:12 +03:00
parent 4ff5ae1315
commit d6003dfb0c
+48 -2
View File
@@ -6400,7 +6400,7 @@ static CGSize kThreadListBarButtonItemImageSize;
BOOL showMoreOption = (event.isState && RiotSettings.shared.roomContextualMenuShowMoreOptionForStates)
|| (!event.isState && RiotSettings.shared.roomContextualMenuShowMoreOptionForMessages);
BOOL showThreadOption = RiotSettings.shared.enableThreads && !self.roomDataSource.threadId && !event.threadId;
BOOL showThreadOption = !self.roomDataSource.threadId && !event.threadId;
NSMutableArray<RoomContextualMenuItem*> *items = [NSMutableArray arrayWithCapacity:5];
@@ -6762,7 +6762,14 @@ static CGSize kThreadListBarButtonItemImageSize;
[self hideContextualMenuAnimated:YES cancelEventSelection:NO completion:nil];
[self openThreadWithId:event.eventId];
if (RiotSettings.shared.enableThreads)
{
[self openThreadWithId:event.eventId];
}
else
{
[self showThreadsBeta];
}
};
return item;
@@ -6813,6 +6820,45 @@ static CGSize kThreadListBarButtonItemImageSize;
completion:nil];
}
- (void)showThreadsBeta
{
if (!self.threadsNoticeModalPresenter)
{
self.threadsNoticeModalPresenter = [SlidingModalPresenter new];
}
[self.threadsNoticeModalPresenter dismissWithAnimated:NO completion:nil];
ThreadsBetaViewController *threadsBetaVC = [ThreadsBetaViewController instantiate];
MXWeakify(self);
threadsBetaVC.didTapEnableButton = ^{
MXStrongifyAndReturnIfNil(self);
[self.threadsNoticeModalPresenter dismissWithAnimated:YES completion:^{
RiotSettings.shared.enableThreads = YES;
MXSDKOptions.sharedInstance.enableThreads = YES;
[self cancelEventSelection];
[self.roomDataSource reload];
}];
};
threadsBetaVC.didTapCancelButton = ^{
MXStrongifyAndReturnIfNil(self);
[self.threadsNoticeModalPresenter dismissWithAnimated:YES completion:^{
[self cancelEventSelection];
}];
};
[self.threadsNoticeModalPresenter present:threadsBetaVC
from:self.presentedViewController?:self
animated:YES
options:SlidingModalPresenter.SpanningOption
completion:nil];
}
- (void)openThreadWithId:(NSString *)threadId
{
if (self.threadsBridgePresenter)