merged element 1.10.12 into bum

This commit is contained in:
Arnfried Griesert
2023-06-07 15:45:59 +02:00
132 changed files with 2750 additions and 2416 deletions
+113 -50
View File
@@ -100,7 +100,7 @@ static CGSize kThreadListBarButtonItemImageSize;
@interface RoomViewController () <UISearchBarDelegate, UIGestureRecognizerDelegate, UIScrollViewAccessibilityDelegate, RoomTitleViewTapGestureDelegate, MXKRoomMemberDetailsViewControllerDelegate, ContactsTableViewControllerDelegate, MXServerNoticesDelegate, RoomContextualMenuViewControllerDelegate,
ReactionsMenuViewModelCoordinatorDelegate, EditHistoryCoordinatorBridgePresenterDelegate, MXKDocumentPickerPresenterDelegate, EmojiPickerCoordinatorBridgePresenterDelegate,
ReactionHistoryCoordinatorBridgePresenterDelegate, CameraPresenterDelegate, MediaPickerCoordinatorBridgePresenterDelegate,
RoomDataSourceDelegate, RoomCreationModalCoordinatorBridgePresenterDelegate, RoomInfoCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, RemoveJitsiWidgetViewDelegate, VoiceMessageControllerDelegate, SpaceDetailPresenterDelegate, UserSuggestionCoordinatorBridgeDelegate, ThreadsCoordinatorBridgePresenterDelegate, ThreadsBetaCoordinatorBridgePresenterDelegate, MXThreadingServiceDelegate, RoomParticipantsInviteCoordinatorBridgePresenterDelegate, RoomInputToolbarViewDelegate, ComposerCreateActionListBridgePresenterDelegate>
RoomDataSourceDelegate, RoomCreationModalCoordinatorBridgePresenterDelegate, RoomInfoCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, RemoveJitsiWidgetViewDelegate, VoiceMessageControllerDelegate, SpaceDetailPresenterDelegate, CompletionSuggestionCoordinatorBridgeDelegate, ThreadsCoordinatorBridgePresenterDelegate, ThreadsBetaCoordinatorBridgePresenterDelegate, MXThreadingServiceDelegate, RoomParticipantsInviteCoordinatorBridgePresenterDelegate, RoomInputToolbarViewDelegate, ComposerCreateActionListBridgePresenterDelegate>
{
// The preview header
@@ -226,8 +226,8 @@ static CGSize kThreadListBarButtonItemImageSize;
@property (nonatomic, strong) ShareManager *shareManager;
@property (nonatomic, strong) EventMenuBuilder *eventMenuBuilder;
@property (nonatomic, strong) UserSuggestionCoordinatorBridge *userSuggestionCoordinator;
@property (nonatomic, weak) IBOutlet UIView *userSuggestionContainerView;
@property (nonatomic, strong) CompletionSuggestionCoordinatorBridge *completionSuggestionCoordinator;
@property (nonatomic, weak) IBOutlet UIView *completionSuggestionContainerView;
@property (nonatomic, readwrite) RoomDisplayConfiguration *displayConfiguration;
@@ -431,7 +431,7 @@ static CGSize kThreadListBarButtonItemImageSize;
[self setupActions];
[self setupUserSuggestionViewIfNeeded];
[self setupCompletionSuggestionViewIfNeeded];
[self.topBannersStackView vc_removeAllSubviews];
}
@@ -713,7 +713,7 @@ static CGSize kThreadListBarButtonItemImageSize;
{
// Retrieve the potential message partially typed during last room display.
// Note: We have to wait for viewDidAppear before updating growingTextView (viewWillAppear is too early)
self.inputToolbarView.attributedTextMessage = self.roomDataSource.partialAttributedTextMessage;
[self.inputToolbarView setPartialContent:self.roomDataSource.partialAttributedTextMessage];
}
[self setMaximisedToolbarIsHiddenIfNeeded: NO];
@@ -1108,12 +1108,14 @@ static CGSize kThreadListBarButtonItemImageSize;
[VoiceMessageMediaServiceProvider.sharedProvider setCurrentRoomSummary:dataSource.room.summary];
_voiceMessageController.roomId = dataSource.roomId;
_userSuggestionCoordinator = [[UserSuggestionCoordinatorBridge alloc] initWithMediaManager:self.roomDataSource.mxSession.mediaManager
_completionSuggestionCoordinator = [[CompletionSuggestionCoordinatorBridge alloc] initWithMediaManager:self.roomDataSource.mxSession.mediaManager
room:dataSource.room
userID:self.roomDataSource.mxSession.myUserId];
_userSuggestionCoordinator.delegate = self;
_completionSuggestionCoordinator.delegate = self;
[self setupUserSuggestionViewIfNeeded];
[self setupCompletionSuggestionViewIfNeeded];
[self updateRoomInputToolbarViewClassIfNeeded];
[self updateTopBanners];
}
@@ -1214,6 +1216,12 @@ static CGSize kThreadListBarButtonItemImageSize;
- (void)updateRoomInputToolbarViewClassIfNeeded
{
Class roomInputToolbarViewClass = [RoomViewController mainToolbarClass];
// If RTE is enabled, delay the toolbar setup until `completionSuggestionCoordinator` is ready.
if (roomInputToolbarViewClass == WysiwygInputToolbarView.class && _completionSuggestionCoordinator == nil)
{
return;
}
BOOL shouldDismissContextualMenu = NO;
@@ -1301,6 +1309,8 @@ static CGSize kThreadListBarButtonItemImageSize;
- (BOOL)sendAsIRCStyleCommandIfPossible:(NSString*)string
{
// Override the default behavior for `/join` command in order to open automatically the joined room
NSString* kMXKSlashCmdJoinRoom = [MXKSlashCommandsHelper commandNameFor:MXKSlashCommandJoinRoom];
if ([string hasPrefix:kMXKSlashCmdJoinRoom])
{
@@ -1337,7 +1347,7 @@ static CGSize kThreadListBarButtonItemImageSize;
else
{
// Display cmd usage in text input as placeholder
self.inputToolbarView.placeholder = @"Usage: /join <room_alias>";
self.inputToolbarView.placeholder = [MXKSlashCommandsHelper commandUsageFor:MXKSlashCommandJoinRoom];
}
return YES;
}
@@ -2770,13 +2780,13 @@ static CGSize kThreadListBarButtonItemImageSize;
}
}
- (void)setupUserSuggestionViewIfNeeded
- (void)setupCompletionSuggestionViewIfNeeded
{
if(!self.isViewLoaded) {
return;
}
UIViewController *suggestionsViewController = self.userSuggestionCoordinator.toPresentable;
UIViewController *suggestionsViewController = self.completionSuggestionCoordinator.toPresentable;
if (!suggestionsViewController)
{
@@ -2786,12 +2796,12 @@ static CGSize kThreadListBarButtonItemImageSize;
[suggestionsViewController.view setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addChildViewController:suggestionsViewController];
[self.userSuggestionContainerView addSubview:suggestionsViewController.view];
[self.completionSuggestionContainerView addSubview:suggestionsViewController.view];
[NSLayoutConstraint activateConstraints:@[[suggestionsViewController.view.topAnchor constraintEqualToAnchor:self.userSuggestionContainerView.topAnchor],
[suggestionsViewController.view.leadingAnchor constraintEqualToAnchor:self.userSuggestionContainerView.leadingAnchor],
[suggestionsViewController.view.trailingAnchor constraintEqualToAnchor:self.userSuggestionContainerView.trailingAnchor],
[suggestionsViewController.view.bottomAnchor constraintEqualToAnchor:self.userSuggestionContainerView.bottomAnchor],]];
[NSLayoutConstraint activateConstraints:@[[suggestionsViewController.view.topAnchor constraintEqualToAnchor:self.completionSuggestionContainerView.topAnchor],
[suggestionsViewController.view.leadingAnchor constraintEqualToAnchor:self.completionSuggestionContainerView.leadingAnchor],
[suggestionsViewController.view.trailingAnchor constraintEqualToAnchor:self.completionSuggestionContainerView.trailingAnchor],
[suggestionsViewController.view.bottomAnchor constraintEqualToAnchor:self.completionSuggestionContainerView.bottomAnchor],]];
[suggestionsViewController didMoveToParentViewController:self];
}
@@ -5202,17 +5212,17 @@ static CGSize kThreadListBarButtonItemImageSize;
- (void)roomInputToolbarViewDidChangeTextMessage:(RoomInputToolbarView *)toolbarView
{
[self.userSuggestionCoordinator processTextMessage:toolbarView.textMessage];
[self.completionSuggestionCoordinator processTextMessage:toolbarView.textMessage];
}
- (void)didDetectTextPattern:(SuggestionPatternWrapper *)suggestionPattern
{
[self.userSuggestionCoordinator processSuggestionPattern:suggestionPattern];
[self.completionSuggestionCoordinator processSuggestionPattern:suggestionPattern];
}
- (UserSuggestionViewModelContextWrapper *)userSuggestionContext
- (CompletionSuggestionViewModelContextWrapper *)completionSuggestionContext
{
return [self.userSuggestionCoordinator sharedContext];
return [self.completionSuggestionCoordinator sharedContext];
}
- (MXMediaManager *)mediaManager
@@ -5243,6 +5253,27 @@ static CGSize kThreadListBarButtonItemImageSize;
}];
}
- (void)roomInputToolbarView:(MXKRoomInputToolbarView *)toolbarView sendCommand:(NSString *)commandText
{
// Create before sending the message in case of a discussion (direct chat)
MXWeakify(self);
[self createDiscussionIfNeeded:^(BOOL readyToSend) {
MXStrongifyAndReturnIfNil(self);
if (readyToSend) {
if (![self sendAsIRCStyleCommandIfPossible:commandText])
{
// Display an error for unknown command
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
message:[VectorL10n roomCommandErrorUnknownCommand]
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:[VectorL10n ok] style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alert animated:YES completion:nil];
}
}
}];
}
- (void)roomInputToolbarViewShowSendMediaActions:(MXKRoomInputToolbarView *)toolbarView
{
NSMutableArray *actionItems = [NSMutableArray new];
@@ -5292,7 +5323,7 @@ static CGSize kThreadListBarButtonItemImageSize;
if (readyToSend) {
BOOL isMessageAHandledCommand = NO;
// "/me" command is supported with Pills in RoomDataSource.
if (![attributedTextMessage.string hasPrefix:kMXKSlashCmdEmote])
if (![attributedTextMessage.string hasPrefix:[MXKSlashCommandsHelper commandNameFor:MXKSlashCommandEmote]])
{
// Other commands currently work with identifiers (e.g. ban, invite, op, etc).
NSString *message;
@@ -5317,6 +5348,11 @@ static CGSize kThreadListBarButtonItemImageSize;
}];
}
- (void)roomInputToolbarView:(MXKRoomInputToolbarView *)toolbarView shouldStorePartialContent:(NSAttributedString *)partialAttributedTextMessage
{
self.roomDataSource.partialAttributedTextMessage = partialAttributedTextMessage;
}
#pragma mark - MXKRoomMemberDetailsViewControllerDelegate
- (void)roomMemberDetailsViewController:(MXKRoomMemberDetailsViewController *)roomMemberDetailsViewController startChatWithMemberId:(NSString *)matrixId completion:(void (^)(void))completion
@@ -6169,7 +6205,7 @@ static CGSize kThreadListBarButtonItemImageSize;
if (self.saveProgressTextInput)
{
// Restore the potential message partially typed before jump to last unread messages.
self.inputToolbarView.attributedTextMessage = roomDataSource.partialAttributedTextMessage;
[self.inputToolbarView setPartialContent:roomDataSource.partialAttributedTextMessage];
}
};
@@ -6421,21 +6457,10 @@ static CGSize kThreadListBarButtonItemImageSize;
self->currentAlert = nil;
// Acknowledge the existence of all devices
[self startActivityIndicator];
self->unknownDevices = nil;
if (![self.mainSession.crypto isKindOfClass:[MXLegacyCrypto class]])
{
MXLogFailure(@"[RoomVC] eventDidChangeSentState: Only legacy crypto supports manual setting of known devices");
return;
}
[(MXLegacyCrypto *)self.mainSession.crypto setDevicesKnown:self->unknownDevices complete:^{
self->unknownDevices = nil;
[self stopActivityIndicator];
// And resend pending messages
[self resendAllUnsentMessages];
}];
// And resend pending messages
[self resendAllUnsentMessages];
}
}]];
@@ -7558,23 +7583,47 @@ static CGSize kThreadListBarButtonItemImageSize;
return;
}
NSMutableArray<NSIndexPath *> *rowsToReload = [[NSMutableArray alloc] init];
// Get the current hightlighted event because we will need to reload it
NSString *currentHiglightedEventId = self.customizedRoomDataSource.highlightedEventId;
if (currentHiglightedEventId)
{
NSInteger currentHiglightedRow = [self.roomDataSource indexOfCellDataWithEventId:currentHiglightedEventId];
if (currentHiglightedRow != NSNotFound)
{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:currentHiglightedRow inSection:0];
if ([[self.bubblesTableView indexPathsForVisibleRows] containsObject:indexPath])
{
[rowsToReload addObject:indexPath];
}
}
}
self.customizedRoomDataSource.highlightedEventId = eventId;
// Add the new highligted event to the list of rows to reload
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
if ([[self.bubblesTableView indexPathsForVisibleRows] containsObject:indexPath])
BOOL indexPathIsVisible = [[self.bubblesTableView indexPathsForVisibleRows] containsObject:indexPath];
if (indexPathIsVisible)
{
[self.bubblesTableView reloadRowsAtIndexPaths:@[indexPath]
[rowsToReload addObject:indexPath];
}
// Reload rows
if (rowsToReload.count > 0)
{
[self.bubblesTableView reloadRowsAtIndexPaths:rowsToReload
withRowAnimation:UITableViewRowAnimationNone];
[self.bubblesTableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionMiddle
animated:YES];
}
else if ([self.bubblesTableView vc_hasIndexPath:indexPath])
// Scroll to the newly highlighted row
if (indexPathIsVisible || [self.bubblesTableView vc_hasIndexPath:indexPath])
{
[self.bubblesTableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionMiddle
animated:YES];
}
if (completion)
{
completion();
@@ -8152,8 +8201,6 @@ static CGSize kThreadListBarButtonItemImageSize;
[[LegacyAppDelegate theDelegate] openSpaceWithId:spaceId];
}
#pragma mark - Bwi Measurements
- (void) finishTextMessageProfil:(PerformanceProfile*)profile {
[profile stopMeasurement];
if( [profile isLogable] ) {
@@ -8179,7 +8226,7 @@ static CGSize kThreadListBarButtonItemImageSize;
#pragma mark - UserSuggestionCoordinatorBridgeDelegate
- (void)userSuggestionCoordinatorBridge:(UserSuggestionCoordinatorBridge *)coordinator
- (void)completionSuggestionCoordinatorBridge:(CompletionSuggestionCoordinatorBridge *)coordinator
didRequestMentionForMember:(MXRoomMember *)member
textTrigger:(NSString *)textTrigger
{
@@ -8187,16 +8234,32 @@ static CGSize kThreadListBarButtonItemImageSize;
[self mention:member];
}
- (void)userSuggestionCoordinatorBridgeDidRequestMentionForRoom:(UserSuggestionCoordinatorBridge *)coordinator
- (void)completionSuggestionCoordinatorBridgeDidRequestMentionForRoom:(CompletionSuggestionCoordinatorBridge *)coordinator
textTrigger:(NSString *)textTrigger
{
[self removeTriggerTextFromComposer:textTrigger];
[self.inputToolbarView pasteText:[UserSuggestionID.room stringByAppendingString:@" "]];
[self.inputToolbarView pasteText:[CompletionSuggestionUserID.room stringByAppendingString:@" "]];
}
- (void)completionSuggestionCoordinatorBridge:(CompletionSuggestionCoordinatorBridge *)coordinator
didRequestCommand:(NSString *)command
textTrigger:(NSString *)textTrigger
{
[self removeTriggerTextFromComposer:textTrigger];
[self setCommand:command];
}
- (void)removeTriggerTextFromComposer:(NSString *)textTrigger
{
RoomInputToolbarView *toolbar = (RoomInputToolbarView *)self.inputToolbarView;
Class roomInputToolbarViewClass = [RoomViewController mainToolbarClass];
// RTE handles removing the text trigger by itself.
if (roomInputToolbarViewClass == WysiwygInputToolbarView.class && RiotSettings.shared.enableWysiwygTextFormatting)
{
return;
}
if (toolbar && textTrigger.length) {
NSMutableAttributedString *attributedTextMessage = [[NSMutableAttributedString alloc] initWithAttributedString:toolbar.attributedTextMessage];
[[attributedTextMessage mutableString] replaceOccurrencesOfString:textTrigger
@@ -8207,11 +8270,11 @@ static CGSize kThreadListBarButtonItemImageSize;
}
}
- (void)userSuggestionCoordinatorBridge:(UserSuggestionCoordinatorBridge *)coordinator didUpdateViewHeight:(CGFloat)height
- (void)completionSuggestionCoordinatorBridge:(CompletionSuggestionCoordinatorBridge *)coordinator didUpdateViewHeight:(CGFloat)height
{
if (self.userSuggestionContainerHeightConstraint.constant != height)
if (self.completionSuggestionContainerHeightConstraint.constant != height)
{
self.userSuggestionContainerHeightConstraint.constant = height;
self.completionSuggestionContainerHeightConstraint.constant = height;
[self.view layoutIfNeeded];
}