mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-27 11:46:58 +02:00
Merge branch 'gil/pre_release_fixes' into gil/4498_Handle_space_link
This commit is contained in:
@@ -633,7 +633,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
self.updateRoomReadMarker = NO;
|
||||
isAppeared = NO;
|
||||
|
||||
[VoiceMessageMediaServiceProvider.sharedProvider stopAllServices];
|
||||
[VoiceMessageMediaServiceProvider.sharedProvider pauseAllServices];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
@@ -4429,27 +4429,48 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
else if (tappedView == previewHeader.rightButton)
|
||||
{
|
||||
// 'Join' button has been pressed
|
||||
if (roomPreviewData)
|
||||
if (!roomPreviewData)
|
||||
{
|
||||
// Attempt to join the room (keep reference on the potential eventId, the preview data will be removed automatically in case of success).
|
||||
NSString *eventId = roomPreviewData.eventId;
|
||||
[self joinRoom:^(MXKRoomViewControllerJoinRoomResult result) {
|
||||
switch (result)
|
||||
{
|
||||
case MXKRoomViewControllerJoinRoomResultSuccess:
|
||||
[self refreshRoomTitle];
|
||||
break;
|
||||
case MXKRoomViewControllerJoinRoomResultFailureRoomEmpty:
|
||||
[self declineRoomInvitation];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}];
|
||||
|
||||
// We promote here join by room alias instead of room id when an alias is available.
|
||||
NSString *roomIdOrAlias = roomPreviewData.roomId;
|
||||
return;
|
||||
}
|
||||
|
||||
// Attempt to join the room (keep reference on the potential eventId, the preview data will be removed automatically in case of success).
|
||||
NSString *eventId = roomPreviewData.eventId;
|
||||
|
||||
// We promote here join by room alias instead of room id when an alias is available.
|
||||
NSString *roomIdOrAlias = roomPreviewData.roomId;
|
||||
|
||||
if (roomPreviewData.roomCanonicalAlias.length)
|
||||
{
|
||||
roomIdOrAlias = roomPreviewData.roomCanonicalAlias;
|
||||
}
|
||||
else if (roomPreviewData.roomAliases.count)
|
||||
{
|
||||
roomIdOrAlias = roomPreviewData.roomAliases.firstObject;
|
||||
}
|
||||
|
||||
// Note in case of simple link to a room the signUrl param is nil
|
||||
[self joinRoomWithRoomIdOrAlias:roomIdOrAlias viaServers:roomPreviewData.viaServers
|
||||
andSignUrl:roomPreviewData.emailInvitation.signUrl
|
||||
completion:^(MXKRoomViewControllerJoinRoomResult result) {
|
||||
|
||||
if (roomPreviewData.roomCanonicalAlias.length)
|
||||
switch (result)
|
||||
{
|
||||
roomIdOrAlias = roomPreviewData.roomCanonicalAlias;
|
||||
}
|
||||
else if (roomPreviewData.roomAliases.count)
|
||||
{
|
||||
roomIdOrAlias = roomPreviewData.roomAliases.firstObject;
|
||||
}
|
||||
|
||||
// Note in case of simple link to a room the signUrl param is nil
|
||||
[self joinRoomWithRoomIdOrAlias:roomIdOrAlias viaServers:roomPreviewData.viaServers andSignUrl:roomPreviewData.emailInvitation.signUrl completion:^(BOOL succeed) {
|
||||
|
||||
if (succeed)
|
||||
case MXKRoomViewControllerJoinRoomResultSuccess:
|
||||
{
|
||||
// If an event was specified, replace the datasource by a non live datasource showing the event
|
||||
if (eventId)
|
||||
@@ -4478,33 +4499,47 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
[self refreshRoomTitle];
|
||||
[self refreshRoomInputToolbar];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self joinRoom:^(BOOL succeed) {
|
||||
|
||||
if (succeed)
|
||||
{
|
||||
[self refreshRoomTitle];
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
case MXKRoomViewControllerJoinRoomResultFailureRoomEmpty:
|
||||
[self declineRoomInvitation];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}];
|
||||
}
|
||||
else if (tappedView == previewHeader.leftButton)
|
||||
{
|
||||
// 'Decline' button has been pressed
|
||||
if (roomPreviewData)
|
||||
{
|
||||
[self roomPreviewDidTapCancelAction];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self leaveRoom];
|
||||
}
|
||||
[self declineRoomInvitation];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)declineRoomInvitation
|
||||
{
|
||||
// 'Decline' button has been pressed
|
||||
if (roomPreviewData)
|
||||
{
|
||||
[self roomPreviewDidTapCancelAction];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self startActivityIndicator];
|
||||
|
||||
[self.roomDataSource.room leave:^{
|
||||
|
||||
[self stopActivityIndicator];
|
||||
|
||||
// We remove the current view controller.
|
||||
// Pop to homes view controller
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
|
||||
[self stopActivityIndicator];
|
||||
MXLogDebug(@"[RoomVC] Failed to reject an invited room (%@) failed", self.roomDataSource.room.roomId);
|
||||
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,13 @@ import MediaPlayer
|
||||
|
||||
private var displayLink: CADisplayLink!
|
||||
|
||||
// Retain currently playing audio player so it doesn't stop playing on timeline cell reuse
|
||||
|
||||
|
||||
// Retain active audio players(playing or paused) so it doesn't stop playing on timeline cell reuse
|
||||
// and we can pause/resume players on switching rooms.
|
||||
private var activeAudioPlayers: Set<VoiceMessageAudioPlayer>
|
||||
|
||||
// Keep reference to currently playing player for remote control.
|
||||
private var currentlyPlayingAudioPlayer: VoiceMessageAudioPlayer?
|
||||
|
||||
@objc public static let sharedProvider = VoiceMessageMediaServiceProvider()
|
||||
@@ -87,7 +93,7 @@ import MediaPlayer
|
||||
private override init() {
|
||||
audioPlayers = NSMapTable<NSString, VoiceMessageAudioPlayer>(valueOptions: .weakMemory)
|
||||
audioRecorders = NSHashTable<VoiceMessageAudioRecorder>(options: .weakMemory)
|
||||
|
||||
activeAudioPlayers = Set<VoiceMessageAudioPlayer>()
|
||||
super.init()
|
||||
|
||||
displayLink = CADisplayLink(target: WeakTarget(self, selector: #selector(handleDisplayLinkTick)), selector: WeakTarget.triggerSelector)
|
||||
@@ -113,16 +119,17 @@ import MediaPlayer
|
||||
return audioRecorder
|
||||
}
|
||||
|
||||
@objc func stopAllServices() {
|
||||
stopAllServicesExcept(nil)
|
||||
@objc func pauseAllServices() {
|
||||
pauseAllServicesExcept(nil)
|
||||
}
|
||||
|
||||
// MARK: - VoiceMessageAudioPlayerDelegate
|
||||
|
||||
func audioPlayerDidStartPlaying(_ audioPlayer: VoiceMessageAudioPlayer) {
|
||||
currentlyPlayingAudioPlayer = audioPlayer
|
||||
activeAudioPlayers.insert(audioPlayer)
|
||||
setUpRemoteCommandCenter()
|
||||
stopAllServicesExcept(audioPlayer)
|
||||
pauseAllServicesExcept(audioPlayer)
|
||||
}
|
||||
|
||||
func audioPlayerDidStopPlaying(_ audioPlayer: VoiceMessageAudioPlayer) {
|
||||
@@ -130,6 +137,7 @@ import MediaPlayer
|
||||
currentlyPlayingAudioPlayer = nil
|
||||
tearDownRemoteCommandCenter()
|
||||
}
|
||||
activeAudioPlayers.remove(audioPlayer)
|
||||
}
|
||||
|
||||
func audioPlayerDidFinishPlaying(_ audioPlayer: VoiceMessageAudioPlayer) {
|
||||
@@ -137,17 +145,18 @@ import MediaPlayer
|
||||
currentlyPlayingAudioPlayer = nil
|
||||
tearDownRemoteCommandCenter()
|
||||
}
|
||||
activeAudioPlayers.remove(audioPlayer)
|
||||
}
|
||||
|
||||
// MARK: - VoiceMessageAudioRecorderDelegate
|
||||
|
||||
func audioRecorderDidStartRecording(_ audioRecorder: VoiceMessageAudioRecorder) {
|
||||
stopAllServicesExcept(audioRecorder)
|
||||
pauseAllServicesExcept(audioRecorder)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func stopAllServicesExcept(_ service: AnyObject?) {
|
||||
private func pauseAllServicesExcept(_ service: AnyObject?) {
|
||||
for audioRecorder in audioRecorders.allObjects {
|
||||
if audioRecorder === service {
|
||||
continue
|
||||
@@ -165,8 +174,7 @@ import MediaPlayer
|
||||
continue
|
||||
}
|
||||
|
||||
audioPlayer.stop()
|
||||
audioPlayer.unloadContent()
|
||||
audioPlayer.pause()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user