Skip to content

Commit

Permalink
Merge branch 'release/0.22.0/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Feb 9, 2022
2 parents f9f71bd + d71b7bb commit 812dd3e
Show file tree
Hide file tree
Showing 139 changed files with 4,680 additions and 1,233 deletions.
37 changes: 37 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
## Changes in 0.22.0 (2022-02-09)

✨ Features

- Add .well-known parsing for tile server / map style configurations. ([#5298](https://github.com/vector-im/element-ios/issues/5298))

🙌 Improvements

- Introduce `MXThreadingService` and `MXThread` classes. ([#5068](https://github.com/vector-im/element-ios/issues/5068))
- MXThreadingService: Expose threads of a room. ([#5092](https://github.com/vector-im/element-ios/issues/5092))
- Threads: Include redacted root events into threads. ([#5119](https://github.com/vector-im/element-ios/issues/5119))
- MXSession: Avoid event/null requests and reprocess bg sync cache if received when processing. ([#5426](https://github.com/vector-im/element-ios/issues/5426))
- MXRoomListDataFetcherDelegate: Add `totalCountsChanged` parameter to delegate method. ([#5448](https://github.com/vector-im/element-ios/issues/5448))

🐛 Bugfixes

- 🐛 Protect the spacesPerId variable by a barrier - Fixes Thread 1: EXC_BAD_ACCESS crash that would occur whenever multiple concurrent threads would attempt to mutate spacesPerId at the same time ([#1350](https://github.com/vector-im/element-ios/issues/1350))
- Fix for display name and avatar shown incorrectly for users that have left the room. ([#2827](https://github.com/vector-im/element-ios/issues/2827))
- Protect against encryption state loss ([#5184](https://github.com/vector-im/element-ios/issues/5184))
- MXSpace: fix space invites blocks space graph build ([#5432](https://github.com/vector-im/element-ios/issues/5432))
- MXCoreDataRoomSummaryStore: Fix main context merges from persistent store. ([#5462](https://github.com/vector-im/element-ios/issues/5462))
- MXSession: Do not pause the session if a sync fails due to cancellation. ([#5509](https://github.com/vector-im/element-ios/issues/5509))
- CoreData: Fix fetch requests fetching only specific properties. ([#5519](https://github.com/vector-im/element-ios/issues/5519))

⚠️ API Changes

- MXRestClient & MXRoom: Introduce `threadId` parameters for event sending methods. ([#5068](https://github.com/vector-im/element-ios/issues/5068))

🧱 Build

- Update Fastfile to use Xcode 13.2 on CI. ([#4883](https://github.com/vector-im/element-ios/issues/4883))

Others

- Add WIP to towncrier. ([#1349](https://github.com/matrix-org/matrix-ios-sdk/pull/1349))


## Changes in 0.21.0 (2022-01-25)

✨ Features
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ following:
- `i18n` for translations
- `build` for changes related to build, tools, CI/CD
- `doc` for updates to the documentation
- `wip` for anything that isn't ready to ship and will be enabled at a later date
- `misc` for other changes

This file will become part of our [changelog](CHANGES.md) at the next
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.21.0"
s.version = "0.22.0"
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"

s.description = <<-DESC
Expand Down
178 changes: 157 additions & 21 deletions MatrixSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions MatrixSDK/Aggregations/MXAggregatedEditsUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ - (MXHTTPOperation*)replaceTextMessageEvent:(MXEvent*)event

content[@"m.new_content"] = newContent;

content[@"m.relates_to"] = @{
@"rel_type" : @"m.replace",
@"event_id": event.eventId
};
content[kMXEventRelationRelatesToKey] = @{
@"rel_type" : @"m.replace",
@"event_id": event.eventId
};

MXHTTPOperation *operation;
MXEvent *localEcho;
Expand Down Expand Up @@ -170,13 +170,13 @@ - (MXHTTPOperation*)replaceTextMessageEvent:(MXEvent*)event
if (localEchoBlock)
{
// Build a temporary local echo
localEcho = [room fakeEventWithEventId:nil eventType:kMXEventTypeStringRoomMessage andContent:content];
localEcho = [room fakeEventWithEventId:nil eventType:kMXEventTypeStringRoomMessage andContent:content threadId:nil];
localEcho.sentState = event.sentState;
}
}
else
{
operation = [room sendEventOfType:kMXEventTypeStringRoomMessage content:content localEcho:&localEcho success:success failure:failure];
operation = [room sendEventOfType:kMXEventTypeStringRoomMessage content:content threadId:nil localEcho:&localEcho success:success failure:failure];
}

if (localEchoBlock && localEcho)
Expand Down
16 changes: 8 additions & 8 deletions MatrixSDK/Aggregations/MXAggregatedReactionsUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,14 @@ - (MXHTTPOperation*)sendReaction:(NSString*)reaction
}

NSDictionary *reactionContent = @{
@"m.relates_to": @{
@"rel_type": @"m.annotation",
@"event_id": eventId,
@"key": reaction
}
};

return [room sendEventOfType:kMXEventTypeStringReaction content:reactionContent localEcho:nil success:^(NSString *eventId) {
kMXEventRelationRelatesToKey: @{
@"rel_type": @"m.annotation",
@"event_id": eventId,
@"key": reaction
}
};

return [room sendEventOfType:kMXEventTypeStringReaction content:reactionContent threadId:nil localEcho:nil success:^(NSString *eventId) {
success();
} failure:failure];
}
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Aggregations/MXAggregations.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
@param failure A block object called when the operation fails.
*/
- (void)addReaction:(NSString*)reaction
forEvent:(NSString*)eventId
forEvent:(NSString*)eventId
inRoom:(NSString*)roomId
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure;
Expand Down
4 changes: 2 additions & 2 deletions MatrixSDK/Background/MXBackgroundStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class MXBackgroundStore: NSObject, MXStore {
func open(with credentials: MXCredentials, onComplete: (() -> Void)?, failure: ((Error?) -> Void)? = nil) {
}

func storeEvent(forRoom roomId: String, event: MXEvent, direction: __MXTimelineDirection) {
func storeEvent(forRoom roomId: String, event: MXEvent, direction: MXTimelineDirection) {
}

func replace(_ event: MXEvent, inRoom roomId: String) {
Expand Down Expand Up @@ -228,7 +228,7 @@ class MXBackgroundStore: NSObject, MXStore {
}
}

func localUnreadEventCount(_ roomId: String, withTypeIn types: [Any]?) -> UInt {
func localUnreadEventCount(_ roomId: String, threadId: String?, withTypeIn types: [Any]?) -> UInt {
return 0
}

Expand Down
4 changes: 2 additions & 2 deletions MatrixSDK/Background/MXBackgroundSyncService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public enum MXBackgroundSyncServiceError: Error {

/// Initializer
/// - Parameter credentials: account credentials
public init(withCredentials credentials: MXCredentials) {
public init(withCredentials credentials: MXCredentials, persistTokenDataHandler: MXRestClientPersistTokenDataHandler? = nil, unauthenticatedHandler: MXRestClientUnauthenticatedHandler? = nil) {
processingQueue = DispatchQueue(label: "MXBackgroundSyncServiceQueue-" + MXTools.generateSecret())
self.credentials = credentials

Expand All @@ -76,7 +76,7 @@ public enum MXBackgroundSyncServiceError: Error {
let syncResponseStore = MXSyncResponseFileStore(withCredentials: credentials)
syncResponseStoreManager = MXSyncResponseStoreManager(syncResponseStore: syncResponseStore)

restClient = MXRestClient(credentials: credentials, unrecognizedCertificateHandler: nil)
restClient = MXRestClient(credentials: credentials, unrecognizedCertificateHandler: nil, persistentTokenDataHandler: persistTokenDataHandler, unauthenticatedHandler: unauthenticatedHandler)
restClient.completionQueue = processingQueue
store = MXBackgroundStore(withCredentials: credentials)
// We can flush any crypto data if our sync response store is empty
Expand Down
1 change: 1 addition & 0 deletions MatrixSDK/Background/Store/MXSyncResponseStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum MXSyncResponseStoreError: Error {
func syncResponseSize(withId id: String) -> Int
func updateSyncResponse(withId id: String, syncResponse: MXCachedSyncResponse)
func deleteSyncResponse(withId id: String)
func deleteSyncResponses(withIds ids: [String])

/// All ids of valid stored sync responses.
/// Sync responses are stored in chunks to save RAM when processing it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,13 @@ public class MXSyncResponseFileStore: NSObject {
}

private func deleteSyncResponseId(id: String) {
deleteSyncResponseIds(ids: [id])
}

private func deleteSyncResponseIds(ids: [String]) {
var metadata = readMetaData()
metadata.syncResponseIds.removeAll(where: { $0 == id })
metadata.outdatedSyncResponseIds.removeAll(where: { $0 == id })
metadata.syncResponseIds.removeAll(where: { ids.contains($0) })
metadata.outdatedSyncResponseIds.removeAll(where: { ids.contains($0) })
saveMetaData(metadata)
}
}
Expand Down Expand Up @@ -219,6 +223,13 @@ extension MXSyncResponseFileStore: MXSyncResponseStore {
saveSyncResponse(path: syncResponsePath(withId: id), syncResponse: nil)
deleteSyncResponseId(id: id)
}

public func deleteSyncResponses(withIds ids: [String]) {
for id in ids {
saveSyncResponse(path: syncResponsePath(withId: id), syncResponse: nil)
}
deleteSyncResponseIds(ids: ids)
}

public var syncResponseIds: [String] {
readMetaData().syncResponseIds
Expand Down
32 changes: 32 additions & 0 deletions MatrixSDK/Categories/NSDictionary+MutableDeepCopy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Copyright 2021 The Matrix.org Foundation C.I.C
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@protocol MutableDeepCopying <NSObject>
- (id)mutableDeepCopy;
@end

@interface NSDictionary (MutableDeepCopy) <MutableDeepCopying>

@end

@interface NSArray (MutableDeepCopy) <MutableDeepCopying>
@end

NS_ASSUME_NONNULL_END
88 changes: 88 additions & 0 deletions MatrixSDK/Categories/NSDictionary+MutableDeepCopy.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//
// Copyright 2021 The Matrix.org Foundation C.I.C
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import "NSDictionary+MutableDeepCopy.h"

@implementation NSDictionary (MutableDeepCopy)

- (NSMutableDictionary *)mutableDeepCopy
{
NSMutableDictionary *result = [NSMutableDictionary dictionaryWithCapacity:self.count];
NSArray *keys = [self allKeys];

for (id key in keys)
{
id object = [self objectForKey:key];
id value = nil;
if ([object conformsToProtocol:@protocol(MutableDeepCopying)])
{
value = [object mutableDeepCopy];
}
else if ([object conformsToProtocol:@protocol(NSMutableCopying)])
{
value = [object mutableCopy];
}
else if ([object conformsToProtocol:@protocol(NSCopying)])
{
value = [object copy];
}
else
{
value = object;
}

[result setValue:value forKey:key];
}

return result;
}

@end

@implementation NSArray (MutableDeepCopy)

-(NSMutableArray *)mutableDeepCopy
{
NSMutableArray *result = [NSMutableArray arrayWithCapacity:self.count];

for (id object in self)
{
id value = nil;

if ([object conformsToProtocol:@protocol(MutableDeepCopying)])
{
value = [object mutableDeepCopy];
}
else if ([object conformsToProtocol:@protocol(NSMutableCopying)])
{
value = [object mutableCopy];
}
else if ([object conformsToProtocol:@protocol(NSCopying)])
{
value = [object copy];
}
else
{
value = object;
}

[result addObject:value];
}

return result;
}

@end
46 changes: 6 additions & 40 deletions MatrixSDK/Contrib/Swift/Data/MXEventTimeline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,8 @@

import Foundation

/**
Block called when an event of the registered types has been handled in the timeline.
This is a specialisation of the `MXOnEvent` block.
- parameters:
- event: the new event.
- direction: the origin of the event.
- roomState: the room state right before the event.
*/
public typealias MXOnRoomEvent = (_ event: MXEvent, _ direction: MXTimelineDirection, _ roomState: MXRoomState) -> Void

public extension MXEventTimeline {

/**
Check if this timelime can be extended.
This returns true if we either have more events, or if we have a pagination
token which means we can paginate in that direction. It does not necessarily
mean that there are more events available in that direction at this time.
`canPaginate` in forward direction has no meaning for a live timeline.
- parameter direction: The direction to check
- returns: `true` if we can paginate in the given direction.
*/
@nonobjc func canPaginate(_ direction: MXTimelineDirection) -> Bool {
return __canPaginate(direction.identifier)
}


/**
Reset the pagination timelime and start loading the context around its `initialEventId`.
The retrieved (backwards and forwards) events will be sent to registered listeners.
Expand All @@ -58,7 +29,7 @@ public extension MXEventTimeline {
- returns: a `MXHTTPOperation` instance.
*/
@nonobjc @discardableResult func resetPaginationAroundInitialEvent(withLimit limit: UInt, completion: @escaping (_ response: MXResponse<Void>) -> Void) -> MXHTTPOperation {
@discardableResult func resetPaginationAroundInitialEvent(withLimit limit: UInt, completion: @escaping (_ response: MXResponse<Void>) -> Void) -> MXHTTPOperation {
return __resetPaginationAroundInitialEvent(withLimit: limit, success: currySuccess(completion), failure: curryFailure(completion))
}

Expand All @@ -77,8 +48,8 @@ public extension MXEventTimeline {
- returns: a MXHTTPOperation instance. This instance can be nil if no request to the homeserver is required.
*/
@nonobjc @discardableResult func paginate(_ numItems: UInt, direction: MXTimelineDirection, onlyFromStore: Bool, completion: @escaping (_ response: MXResponse<Void>) -> Void) -> MXHTTPOperation? {
return __paginate(numItems, direction: direction.identifier, onlyFromStore: onlyFromStore, complete: currySuccess(completion), failure: curryFailure(completion))
@discardableResult func paginate(_ numItems: UInt, direction: MXTimelineDirection, onlyFromStore: Bool, completion: @escaping (_ response: MXResponse<Void>) -> Void) -> MXHTTPOperation? {
return __paginate(numItems, direction: direction, onlyFromStore: onlyFromStore, complete: currySuccess(completion), failure: curryFailure(completion))
}


Expand All @@ -91,18 +62,13 @@ public extension MXEventTimeline {
- block: the block that will called once a new event has been handled.
- returns: a reference to use to unregister the listener
*/
@nonobjc func listenToEvents(_ types: [MXEventType]? = nil, _ block: @escaping MXOnRoomEvent) -> Any {

let legacyBlock: __MXOnRoomEvent = { (event, direction, state) in
guard let event = event, let state = state else { return }
block(event, MXTimelineDirection(identifer: direction), state)
}
func listenToEvents(_ types: [MXEventType]? = nil, _ block: @escaping MXOnRoomEvent) -> Any {

if let types = types {
let typeStrings = types.map({ return $0.identifier })
return __listen(toEventsOfTypes: typeStrings, onEvent: legacyBlock)
return __listen(toEventsOfTypes: typeStrings, onEvent: block)
} else {
return __listen(toEvents: legacyBlock)
return __listen(toEvents: block)
}
}
}
Loading

0 comments on commit 812dd3e

Please sign in to comment.