Skip to content

Commit

Permalink
Merge branch 'release/0.19.5/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
SBiOSoftWhare committed Jul 22, 2021
2 parents 97fd042 + a169cbf commit 9249ac9
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 24 deletions.
27 changes: 27 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
Changes in 0.19.5 (2021-07-22)
=================================================

✨ Features
*

🙌 Improvements
* MXRoomSummary: Cache local unread event count (vector-im/element-ios/issues/4585).

🐛 Bugfix
* MXCryptoStore: Use UI background task to make sure that write operations complete (vector-im/element-ios/issues/4579).

⚠️ API Changes
*

🗣 Translations
*

🧱 Build
*

Others
*

Improvements:


Changes in 0.19.4 (2021-07-15)
=================================================

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.7.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "MatrixSDK"
s.version = "0.19.4"
s.version = "0.19.5"
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"

s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Contrib/Swift/Data/MXRoom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public extension MXRoom {
- returns: a `MXHTTPOperation` instance.
*/

@nonobjc @discardableResult func sendVoiceMessage(localURL: URL, mimeType: String?, duration: TimeInterval, samples: [Float]?, localEcho: inout MXEvent?, completion: @escaping (_ response: MXResponse<String?>) -> Void) -> MXHTTPOperation {
@nonobjc @discardableResult func sendVoiceMessage(localURL: URL, mimeType: String?, duration: UInt, samples: [Float]?, localEcho: inout MXEvent?, completion: @escaping (_ response: MXResponse<String?>) -> Void) -> MXHTTPOperation {
let boxedSamples = samples?.compactMap { NSNumber(value: $0) }
return __sendVoiceMessage(localURL, mimeType: mimeType, duration: duration, samples: boxedSamples, localEcho: &localEcho, success: currySuccess(completion), failure: curryFailure(completion), keepActualFilename: false)
}
Expand Down
28 changes: 18 additions & 10 deletions MatrixSDK/Crypto/Data/Store/MXRealmCryptoStore/MXRealmCryptoStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import "MXAes.h"
#import "MatrixSDKSwiftHeader.h"
#import "MXRealmHelper.h"
#import "MXBackgroundModeHandler.h"


NSUInteger const kMXRealmCryptoStoreVersion = 16;
Expand Down Expand Up @@ -511,8 +512,11 @@ - (OLMAccount*)account

- (void)performAccountOperationWithBlock:(void (^)(OLMAccount *))block
{
NSDate *startDate = [NSDate date];

// Make sure write operations complete in background to avoid to keep the realm internal lock until the app resumes.
// Thus, other components (Notification Extension Service, Share Extension, ...) will not be blocked by this lock.
id<MXBackgroundModeHandler> handler = [MXSDKOptions sharedInstance].backgroundModeHandler;
id<MXBackgroundTask> backgroundTask = [handler startBackgroundTaskWithName:@"[MXRealmCryptoStore] performAccountOperationWithBlock" expirationHandler:nil];

MXRealmOlmAccount *account = self.accountInCurrentThread;
if (account.olmAccountData)
{
Expand All @@ -539,8 +543,8 @@ - (void)performAccountOperationWithBlock:(void (^)(OLMAccount *))block
MXLogDebug(@"[MXRealmCryptoStore] performAccountOperationWithBlock. Error: No OLMAccount yet");
block(nil);
}
MXLogDebug(@"[MXRealmCryptoStore] performAccountOperationWithBlock done in %.3fms", [[NSDate date] timeIntervalSinceDate:startDate] * 1000);

[backgroundTask stop];
}

- (void)storeDeviceSyncToken:(NSString*)deviceSyncToken
Expand Down Expand Up @@ -872,7 +876,10 @@ - (MXOlmSession*)sessionWithDevice:(NSString*)deviceKey andSessionId:(NSString*)

- (void)performSessionOperationWithDevice:(NSString*)deviceKey andSessionId:(NSString*)sessionId block:(void (^)(MXOlmSession *olmSession))block
{
NSDate *startDate = [NSDate date];
// Make sure write operations complete in background to avoid to keep the realm internal lock until the app resumes.
// Thus, other components (Notification Extension Service, Share Extension, ...) will not be blocked by this lock.
id<MXBackgroundModeHandler> handler = [MXSDKOptions sharedInstance].backgroundModeHandler;
id<MXBackgroundTask> backgroundTask = [handler startBackgroundTaskWithName:@"[MXRealmCryptoStore] performSessionOperationWithDevice" expirationHandler:nil];

RLMRealm *realm = self.realm;

Expand All @@ -898,8 +905,7 @@ - (void)performSessionOperationWithDevice:(NSString*)deviceKey andSessionId:(NSS
}

[realm commitWriteTransaction];

MXLogDebug(@"[MXRealmCryptoStore] performSessionOperationWithDevice done in %.3fms", [[NSDate date] timeIntervalSinceDate:startDate] * 1000);
[backgroundTask stop];
}

- (NSArray<MXOlmSession*>*)sessionsWithDevice:(NSString*)deviceKey;
Expand Down Expand Up @@ -996,7 +1002,10 @@ - (MXOlmInboundGroupSession*)inboundGroupSessionWithId:(NSString*)sessionId andS

- (void)performSessionOperationWithGroupSessionWithId:(NSString*)sessionId senderKey:(NSString*)senderKey block:(void (^)(MXOlmInboundGroupSession *inboundGroupSession))block
{
NSDate *startDate = [NSDate date];
// Make sure write operations complete in background to avoid to keep the realm internal lock until the app resumes.
// Thus, other components (Notification Extension Service, Share Extension, ...) will not be blocked by this lock.
id<MXBackgroundModeHandler> handler = [MXSDKOptions sharedInstance].backgroundModeHandler;
id<MXBackgroundTask> backgroundTask = [handler startBackgroundTaskWithName:@"[MXRealmCryptoStore] performSessionOperationWithGroupSessionWithId" expirationHandler:nil];

RLMRealm *realm = self.realm;

Expand Down Expand Up @@ -1028,8 +1037,7 @@ - (void)performSessionOperationWithGroupSessionWithId:(NSString*)sessionId sende
}

[realm commitWriteTransaction];

MXLogDebug(@"[MXRealmCryptoStore] performSessionOperationWithGroupSessionWithId done in %.3fms", [[NSDate date] timeIntervalSinceDate:startDate] * 1000);
[backgroundTask stop];
}

- (NSArray<MXOlmInboundGroupSession *> *)inboundGroupSessions
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/MXRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ FOUNDATION_EXPORT NSInteger const kMXRoomAlreadyJoinedErrorCode;
*/
- (MXHTTPOperation*)sendVoiceMessage:(NSURL*)fileLocalURL
mimeType:(NSString*)mimeType
duration:(NSTimeInterval)duration
duration:(NSUInteger)duration
samples:(NSArray<NSNumber *> *)samples
localEcho:(MXEvent**)localEcho
success:(void (^)(NSString *eventId))success
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ - (MXHTTPOperation*)sendAudioFile:(NSURL*)fileLocalURL

- (MXHTTPOperation*)sendVoiceMessage:(NSURL*)fileLocalURL
mimeType:(NSString*)mimeType
duration:(NSTimeInterval)duration
duration:(NSUInteger)duration
samples:(NSArray<NSNumber *> *)samples
localEcho:(MXEvent**)localEcho
success:(void (^)(NSString *eventId))success
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/MXRoomSummary.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ FOUNDATION_EXPORT NSUInteger const MXRoomSummaryPaginationChunkSize;
@discussion: The returned count is relative to the local storage. The actual unread messages
for a room may be higher than the returned value.
*/
@property (nonatomic, readonly) NSUInteger localUnreadEventCount;
@property (nonatomic) NSUInteger localUnreadEventCount;

/**
The number of unread messages that match the push notification rules.
Expand Down
25 changes: 20 additions & 5 deletions MatrixSDK/Data/MXRoomSummary.m
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,6 @@ - (void)computeTrust:(BOOL)forceDownload


#pragma mark - Others
- (NSUInteger)localUnreadEventCount
{
// Check for unread events in store
return [store localUnreadEventCount:_roomId withTypeIn:_mxSession.unreadEventTypes];
}

- (BOOL)isDirect
{
Expand Down Expand Up @@ -646,6 +641,21 @@ + (MXMembershipTransitionState)membershipTransitionStateForMembership:(MXMembers
return membershipTransitionState;
}

- (BOOL)updateLocalUnreadEventCount
{
BOOL updated = NO;

NSUInteger localUnreadEventCount = [self.mxSession.store localUnreadEventCount:self.room.roomId withTypeIn:self.mxSession.unreadEventTypes];

if (self.localUnreadEventCount != localUnreadEventCount)
{
self.localUnreadEventCount = localUnreadEventCount;
updated = YES;
}

return updated;
}

#pragma mark - Server sync
- (void)handleStateEvents:(NSArray<MXEvent *> *)stateEvents
{
Expand Down Expand Up @@ -702,6 +712,9 @@ - (void)handleJoinedRoomSync:(MXRoomSync*)roomSync onComplete:(void (^)(void))on
break;
}
}

// Check for unread events in store and update the localUnreadEventCount value if needed
updated |= [self updateLocalUnreadEventCount];

// Store notification counts from unreadNotifications field in /sync response
if (roomSync.unreadNotifications)
Expand Down Expand Up @@ -802,6 +815,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder
_others = [aDecoder decodeObjectForKey:@"others"];
_isEncrypted = [aDecoder decodeBoolForKey:@"isEncrypted"];
_trust = [aDecoder decodeObjectForKey:@"trust"];
_localUnreadEventCount = (NSUInteger)[aDecoder decodeIntegerForKey:@"localUnreadEventCount"];
_notificationCount = (NSUInteger)[aDecoder decodeIntegerForKey:@"notificationCount"];
_highlightCount = (NSUInteger)[aDecoder decodeIntegerForKey:@"highlightCount"];
_directUserId = [aDecoder decodeObjectForKey:@"directUserId"];
Expand Down Expand Up @@ -845,6 +859,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:_trust forKey:@"trust"];
}
[aCoder encodeInteger:(NSInteger)_localUnreadEventCount forKey:@"localUnreadEventCount"];
[aCoder encodeInteger:(NSInteger)_notificationCount forKey:@"notificationCount"];
[aCoder encodeInteger:(NSInteger)_highlightCount forKey:@"highlightCount"];
[aCoder encodeObject:_directUserId forKey:@"directUserId"];
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/Store/MXFileStore/MXFileStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#import "MXSDKOptions.h"
#import "MXTools.h"

static NSUInteger const kMXFileVersion = 73;
static NSUInteger const kMXFileVersion = 74;

static NSString *const kMXFileStoreFolder = @"MXFileStore";
static NSString *const kMXFileStoreMedaDataFile = @"MXFileStore";
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/MatrixSDKVersion.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

#import <Foundation/Foundation.h>

NSString *const MatrixSDKVersion = @"0.19.4";
NSString *const MatrixSDKVersion = @"0.19.5";
2 changes: 1 addition & 1 deletion MatrixSDK/Utils/MXUIKitBackgroundTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ - (void)stop
UIApplication *sharedApplication = [self sharedApplication];
if (sharedApplication)
{
MXLogDebug(@"[MXBackgroundTask] Stop background task #%lu - %@ after %.0fms", (unsigned long)self.identifier, self.name, self.elapsedTime);
MXLogDebug(@"[MXBackgroundTask] Stop background task #%lu - %@ after %.3fms", (unsigned long)self.identifier, self.name, self.elapsedTime);

[sharedApplication endBackgroundTask:self.identifier];
self.identifier = UIBackgroundTaskInvalid;
Expand Down

0 comments on commit 9249ac9

Please sign in to comment.