Merge branch 'develop' into mauroromito/fullscreen_mode_2

# Conflicts:
#	Riot.xcworkspace/xcshareddata/swiftpm/Package.resolved
#	RiotSwiftUI/Modules/Room/Composer/View/Composer.swift
#	project.yml
This commit is contained in:
Mauro Romito
2022-11-15 11:03:28 +01:00
45 changed files with 457 additions and 205 deletions
@@ -2197,6 +2197,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
[[[ReviewSessionAlertSnoozeController alloc] init] clearSnooze];
[TimelinePollProvider.shared reset];
#ifdef MX_CALL_STACK_ENDPOINT
// Erase all created certificates and private keys by MXEndpointCallStack
for (MXKAccount *account in MXKAccountManager.sharedManager.accounts)
@@ -359,11 +359,6 @@ typedef BOOL (^MXKAccountOnCertificateChange)(MXKAccount *mxAccount, NSData *cer
- (void)resetDeviceId;
#pragma mark - Sync filter
/**
Check if the homeserver supports room members lazy loading.
@param completion the check result.
*/
- (void)supportLazyLoadOfRoomMembers:(void (^)(BOOL supportLazyLoadOfRoomMembers))completion;
/**
Call this method at an appropriate time to attempt dehydrating to a new backup device
@@ -55,9 +55,6 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
// We will notify user only once on session failure
BOOL notifyOpenSessionFailure;
// The timer used to postpone server sync on failure
NSTimer* initialServerSyncTimer;
// Reachability observer
id reachabilityObserver;
@@ -934,9 +931,6 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
sessionStateObserver = nil;
}
[initialServerSyncTimer invalidate];
initialServerSyncTimer = nil;
if (userUpdateListener)
{
[mxSession.myUser removeListener:userUpdateListener];
@@ -1136,8 +1130,6 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
// Cancel pending actions
[[NSNotificationCenter defaultCenter] removeObserver:reachabilityObserver];
reachabilityObserver = nil;
[initialServerSyncTimer invalidate];
initialServerSyncTimer = nil;
MXLogDebug(@"[MXKAccount] Pause is delayed due to the session state: %@", [MXTools readableSessionState: mxSession.state]);
}
@@ -1627,8 +1619,6 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
// Cancel potential reachability observer and pending action
[[NSNotificationCenter defaultCenter] removeObserver:reachabilityObserver];
reachabilityObserver = nil;
[initialServerSyncTimer invalidate];
initialServerSyncTimer = nil;
// Sanity check
if (!mxSession || (mxSession.state != MXSessionStateStoreDataReady && mxSession.state != MXSessionStateInitialSyncFailed))
@@ -1694,9 +1684,8 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
if (networkReachabilityManager.isReachable)
{
// The problem is not the network
// Postpone a new attempt in 10 sec
self->initialServerSyncTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(launchInitialServerSync) userInfo:self repeats:NO];
// If we have network, we retry immediately, otherwise the server may clear any cache it has computed thus far
[self launchInitialServerSync];
}
else
{
@@ -2088,14 +2077,15 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
#pragma mark - Sync filter
- (void)supportLazyLoadOfRoomMembers:(void (^)(BOOL supportLazyLoadOfRoomMembers))completion
- (void)supportLazyLoadOfRoomMembersWithMatrixVersion:(MXMatrixVersions *)matrixVersions
completion:(void (^)(BOOL supportLazyLoadOfRoomMembers))completion
{
void(^onUnsupportedLazyLoadOfRoomMembers)(NSError *) = ^(NSError *error) {
completion(NO);
};
// Check if the server supports LL sync filter
MXFilterJSONModel *filter = [self syncFilterWithLazyLoadOfRoomMembers:YES];
MXFilterJSONModel *filter = [self syncFilterWithLazyLoadOfRoomMembers:YES supportsNotificationsForThreads:NO];
[mxSession.store filterIdForFilter:filter success:^(NSString * _Nullable filterId) {
if (filterId)
@@ -2106,8 +2096,8 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
else
{
// Check the Matrix versions supported by the HS
[self.mxSession supportedMatrixVersions:^(MXMatrixVersions *matrixVersions) {
if (matrixVersions)
{
if (matrixVersions.supportLazyLoadMembers)
{
// The HS supports LL
@@ -2117,8 +2107,11 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
{
onUnsupportedLazyLoadOfRoomMembers(nil);
}
} failure:onUnsupportedLazyLoadOfRoomMembers];
}
else
{
completion(NO);
}
}
} failure:onUnsupportedLazyLoadOfRoomMembers];
}
@@ -2133,28 +2126,42 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
// Check settings
BOOL syncWithLazyLoadOfRoomMembersSetting = [MXKAppSettings standardAppSettings].syncWithLazyLoadOfRoomMembers;
if (syncWithLazyLoadOfRoomMembersSetting)
{
// Check if the server supports LL sync filter before enabling it
[self supportLazyLoadOfRoomMembers:^(BOOL supportLazyLoadOfRoomMembers) {
void(^buildSyncFilter)(MXMatrixVersions *) = ^(MXMatrixVersions *matrixVersions) {
BOOL supportsNotificationsForThreads = matrixVersions ? matrixVersions.supportsNotificationsForThreads : NO;
if (syncWithLazyLoadOfRoomMembersSetting)
{
// Check if the server supports LL sync filter before enabling it
[self supportLazyLoadOfRoomMembersWithMatrixVersion:matrixVersions completion:^(BOOL supportLazyLoadOfRoomMembers) {
if (supportLazyLoadOfRoomMembers)
{
completion([self syncFilterWithLazyLoadOfRoomMembers:YES]);
}
else
{
// No support from the HS
// Disable the setting. That will avoid to make a request at every startup
[MXKAppSettings standardAppSettings].syncWithLazyLoadOfRoomMembers = NO;
completion([self syncFilterWithLazyLoadOfRoomMembers:NO]);
}
}];
}
else
{
completion([self syncFilterWithLazyLoadOfRoomMembers:NO]);
}
if (supportLazyLoadOfRoomMembers)
{
completion([self syncFilterWithLazyLoadOfRoomMembers:YES
supportsNotificationsForThreads:supportsNotificationsForThreads]);
}
else
{
// No support from the HS
// Disable the setting. That will avoid to make a request at every startup
[MXKAppSettings standardAppSettings].syncWithLazyLoadOfRoomMembers = NO;
completion([self syncFilterWithLazyLoadOfRoomMembers:NO
supportsNotificationsForThreads:supportsNotificationsForThreads]);
}
}];
}
else
{
completion([self syncFilterWithLazyLoadOfRoomMembers:NO supportsNotificationsForThreads:supportsNotificationsForThreads]);
}
};
[mxSession supportedMatrixVersions:^(MXMatrixVersions *matrixVersions) {
buildSyncFilter(matrixVersions);
} failure:^(NSError *error) {
MXLogWarning(@"[MXAccount] buildSyncFilter: failed to get supported versions: %@", error);
buildSyncFilter(nil);
}];
}
/**
@@ -2163,7 +2170,7 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
@param syncWithLazyLoadOfRoomMembers enable LL support.
@return the sync filter to use.
*/
- (MXFilterJSONModel *)syncFilterWithLazyLoadOfRoomMembers:(BOOL)syncWithLazyLoadOfRoomMembers
- (MXFilterJSONModel *)syncFilterWithLazyLoadOfRoomMembers:(BOOL)syncWithLazyLoadOfRoomMembers supportsNotificationsForThreads:(BOOL)supportsNotificationsForThreads
{
MXFilterJSONModel *syncFilter;
NSUInteger limit = 10;
@@ -2198,11 +2205,11 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
// Set that limit in the filter
if (syncWithLazyLoadOfRoomMembers)
{
syncFilter = [MXFilterJSONModel syncFilterForLazyLoadingWithMessageLimit:limit unreadThreadNotifications:YES];
syncFilter = [MXFilterJSONModel syncFilterForLazyLoadingWithMessageLimit:limit unreadThreadNotifications:supportsNotificationsForThreads];
}
else
{
syncFilter = [MXFilterJSONModel syncFilterWithMessageLimit:limit unreadThreadNotifications:YES];
syncFilter = [MXFilterJSONModel syncFilterWithMessageLimit:limit unreadThreadNotifications:supportsNotificationsForThreads];
}
// TODO: We could extend the filter to match other settings (self.showAllEventsInRoomHistory,
+1
View File
@@ -604,6 +604,7 @@ static CGSize kThreadListBarButtonItemImageSize;
[VoiceMessageMediaServiceProvider.sharedProvider pauseAllServices];
[VoiceBroadcastRecorderProvider.shared pauseRecording];
[VoiceBroadcastPlaybackProvider.shared pausePlaying];
// Stop the loading indicator even if the session is still in progress
[self stopLoadingUserIndicator];
@@ -72,6 +72,10 @@ class VoiceMessageAudioPlayer: NSObject {
return audioPlayer.items()
}
var currentUrl: URL? {
return (audioPlayer?.currentItem?.asset as? AVURLAsset)?.url
}
private(set) var isStopped = true
deinit {
@@ -27,20 +27,25 @@ struct VoiceBroadcastBuilder {
var voiceBroadcast = VoiceBroadcast()
voiceBroadcast.chunks = Set(events.compactMap { event in
let chunks = Set(events.compactMap { event in
buildChunk(event: event, mediaManager: mediaManager, voiceBroadcastStartEventId: voiceBroadcastStartEventId)
})
voiceBroadcast.chunks = chunks
voiceBroadcast.duration = chunks.reduce(0) { $0 + $1.duration}
return voiceBroadcast
}
func buildChunk(event: MXEvent, mediaManager: MXMediaManager, voiceBroadcastStartEventId: String) -> VoiceBroadcastChunk? {
guard let attachment = MXKAttachment(event: event, andMediaManager: mediaManager),
let chunkInfo = event.content[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkType] as? [String: UInt],
let sequence = chunkInfo[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkSequence] else {
let sequence = chunkInfo[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkSequence],
let audio = event.content[kMXMessageContentKeyExtensibleAudioMSC1767] as? [String: UInt],
let duration = audio[kMXMessageContentKeyExtensibleAudioDuration] else {
return nil
}
return VoiceBroadcastChunk(voiceBroadcastInfoEventId: voiceBroadcastStartEventId, sequence: sequence, attachment: attachment)
return VoiceBroadcastChunk(voiceBroadcastInfoEventId: voiceBroadcastStartEventId, sequence: sequence, attachment: attachment, duration: duration)
}
}
@@ -20,13 +20,16 @@ public class VoiceBroadcastChunk: NSObject {
public private(set) var voiceBroadcastInfoEventId: String
public private(set) var sequence: UInt
public private(set) var attachment: MXKAttachment
public private(set) var duration: UInt
public init(voiceBroadcastInfoEventId: String,
sequence: UInt,
attachment: MXKAttachment) {
attachment: MXKAttachment,
duration: UInt) {
self.voiceBroadcastInfoEventId = voiceBroadcastInfoEventId
self.sequence = sequence
self.attachment = attachment
self.duration = duration
}
public static func == (lhs: VoiceBroadcastChunk, rhs: VoiceBroadcastChunk) -> Bool {
@@ -24,4 +24,5 @@ public enum VoiceBroadcastKind {
public struct VoiceBroadcast {
var chunks: Set<VoiceBroadcastChunk> = []
var kind: VoiceBroadcastKind = .player
var duration: UInt = 0
}