mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 00:52:43 +02:00
Merge branch 'develop' into gil/SP1_space_creation
This commit is contained in:
@@ -1073,15 +1073,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
self.jumpToLastUnreadBannerContainer.hidden = YES;
|
||||
|
||||
[super leaveRoomOnEvent:event];
|
||||
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate roomViewControllerDidLeaveRoom:self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:nil];
|
||||
}
|
||||
[self notifyDelegateOnLeaveRoomIfNecessary];
|
||||
}
|
||||
|
||||
// Set the input toolbar according to the current display
|
||||
@@ -1261,33 +1253,69 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
|
||||
- (void)sendTextMessage:(NSString*)msgTxt
|
||||
{
|
||||
if (self.inputToolBarSendMode == RoomInputToolbarViewSendModeReply && customizedRoomDataSource.selectedEventId)
|
||||
// The event modified is always fetch from the actual data source
|
||||
MXEvent *eventModified = [self.roomDataSource eventWithEventId:customizedRoomDataSource.selectedEventId];
|
||||
|
||||
// In the case the event is a reply or and edit, and it's done on a non-live timeline
|
||||
// we have to fetch live timeline in order to display the event properly
|
||||
[self setupRoomDataSourceToResolveEvent:^(MXKRoomDataSource *roomDataSource) {
|
||||
if (self.inputToolBarSendMode == RoomInputToolbarViewSendModeReply && eventModified)
|
||||
{
|
||||
[roomDataSource sendReplyToEvent:eventModified withTextMessage:msgTxt success:nil failure:^(NSError *error) {
|
||||
// Just log the error. The message will be displayed in red in the room history
|
||||
MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed.");
|
||||
}];
|
||||
}
|
||||
else if (self.inputToolBarSendMode == RoomInputToolbarViewSendModeEdit && eventModified)
|
||||
{
|
||||
[roomDataSource replaceTextMessageForEvent:eventModified withTextMessage:msgTxt success:nil failure:^(NSError *error) {
|
||||
// Just log the error. The message will be displayed in red
|
||||
MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed.");
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let the datasource send it and manage the local echo
|
||||
[roomDataSource sendTextMessage:msgTxt success:nil failure:^(NSError *error)
|
||||
{
|
||||
// Just log the error. The message will be displayed in red in the room history
|
||||
MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed.");
|
||||
}];
|
||||
}
|
||||
|
||||
if (self->customizedRoomDataSource.selectedEventId)
|
||||
{
|
||||
[self cancelEventSelection];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setupRoomDataSourceToResolveEvent: (void (^)(MXKRoomDataSource *roomDataSource))onComplete
|
||||
{
|
||||
// If the event occur on timeline not live, use the live data source to resolve event
|
||||
BOOL isLive = self.roomDataSource.isLive;
|
||||
if (!isLive)
|
||||
{
|
||||
[self.roomDataSource sendReplyToEventWithId:customizedRoomDataSource.selectedEventId withTextMessage:msgTxt success:nil failure:^(NSError *error) {
|
||||
// Just log the error. The message will be displayed in red in the room history
|
||||
MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed.");
|
||||
}];
|
||||
}
|
||||
else if (self.inputToolBarSendMode == RoomInputToolbarViewSendModeEdit && customizedRoomDataSource.selectedEventId)
|
||||
{
|
||||
[self.roomDataSource replaceTextMessageForEventWithId:customizedRoomDataSource.selectedEventId withTextMessage:msgTxt success:nil failure:^(NSError *error) {
|
||||
// Just log the error. The message will be displayed in red
|
||||
MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed.");
|
||||
}];
|
||||
if (self.roomDataSourceLive == nil)
|
||||
{
|
||||
MXKRoomDataSourceManager *roomDataSourceManager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:self.mainSession];
|
||||
|
||||
[roomDataSourceManager roomDataSourceForRoom:self.roomDataSource.roomId
|
||||
create:YES
|
||||
onComplete:^(MXKRoomDataSource *roomDataSource) {
|
||||
self.roomDataSourceLive = roomDataSource;
|
||||
[self.roomDataSourceLive finalizeInitialization];
|
||||
onComplete(self.roomDataSourceLive);
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
onComplete(self.roomDataSourceLive);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let the datasource send it and manage the local echo
|
||||
[self.roomDataSource sendTextMessage:msgTxt success:nil failure:^(NSError *error)
|
||||
{
|
||||
// Just log the error. The message will be displayed in red in the room history
|
||||
MXLogDebug(@"[MXKRoomViewController] sendTextMessage failed.");
|
||||
}];
|
||||
}
|
||||
|
||||
if (customizedRoomDataSource.selectedEventId)
|
||||
{
|
||||
[self cancelEventSelection];
|
||||
onComplete(self.roomDataSource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2201,16 +2229,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
[self.roomDataSource.room leave:^{
|
||||
|
||||
[self stopActivityIndicator];
|
||||
|
||||
// We remove the current view controller.
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate roomViewControllerDidLeaveRoom:self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
|
||||
}
|
||||
[self notifyDelegateOnLeaveRoomIfNecessary];
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
|
||||
@@ -2220,6 +2239,22 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)notifyDelegateOnLeaveRoomIfNecessary {
|
||||
if (self.delegate)
|
||||
{
|
||||
// Leaving room often triggers multiple events, incl local delegate callbacks as well as global notifications,
|
||||
// which may lead to multiple identical UI changes (navigating to home, displaying notification etc).
|
||||
// To avoid this, as soon as we notify the delegate the first time, we nilify it, preventing future messages
|
||||
// from being passed along, assuming that after leaving a room there is nothing else to communicate to the delegate.
|
||||
[self.delegate roomViewControllerDidLeaveRoom:self];
|
||||
self.delegate = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)roomPreviewDidTapCancelAction
|
||||
{
|
||||
// Decline this invitation = leave this page
|
||||
@@ -7040,14 +7075,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
|
||||
- (void)roomInfoCoordinatorBridgePresenterDelegateDidLeaveRoom:(RoomInfoCoordinatorBridgePresenter *)coordinatorBridgePresenter
|
||||
{
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate roomViewControllerDidLeaveRoom:self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:nil];
|
||||
}
|
||||
[self notifyDelegateOnLeaveRoomIfNecessary];
|
||||
}
|
||||
|
||||
- (void)roomInfoCoordinatorBridgePresenter:(RoomInfoCoordinatorBridgePresenter *)coordinatorBridgePresenter didReplaceRoomWithReplacementId:(NSString *)roomId
|
||||
|
||||
Reference in New Issue
Block a user