Skip to content

Commit

Permalink
Merge branch 'release/0.23.1/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Mar 28, 2022
2 parents b437f1e + 3796a63 commit f041bdc
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 6 deletions.
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## Changes in 0.23.1 (2022-03-28)

🙌 Improvements

- MXRestClient: Use the stable hierarchy endpoint from MSC2946 ([#5144](https://github.com/vector-im/element-ios/issues/5144))

🐛 Bugfixes

- Sync Spaces order with web ([#5134](https://github.com/vector-im/element-ios/issues/5134))


## Changes in 0.23.0 (2022-03-22)

✨ Features
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.23.0"
s.version = "0.23.1"
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"

s.description = <<-DESC
Expand Down
6 changes: 5 additions & 1 deletion MatrixSDK/Contrib/Swift/JSONModels/MXEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public enum MXEventType: Equatable, Hashable {
case keyVerificationDone
case taggedEvents
case spaceChild
case spaceOrder

case pollStart
case pollResponse
Expand Down Expand Up @@ -126,6 +127,7 @@ public enum MXEventType: Equatable, Hashable {
case .keyVerificationDone: return kMXEventTypeStringKeyVerificationDone
case .taggedEvents: return kMXEventTypeStringTaggedEvents
case .spaceChild: return kMXEventTypeStringSpaceChild
case .spaceOrder: return kMXEventTypeStringSpaceOrderMSC3230

case .pollStart: return kMXEventTypeStringPollStartMSC3381
case .pollResponse: return kMXEventTypeStringPollResponseMSC3381
Expand All @@ -140,7 +142,7 @@ public enum MXEventType: Equatable, Hashable {
}

public init(identifier: String) {
let events: [MXEventType] = [.roomName, .roomTopic, .roomAvatar, .roomMember, .roomCreate, .roomJoinRules, .roomPowerLevels, .roomAliases, .roomCanonicalAlias, .roomEncrypted, .roomEncryption, .roomGuestAccess, .roomHistoryVisibility, .roomKey, .roomForwardedKey, .roomKeyRequest, .roomMessage, .roomMessageFeedback, .roomRedaction, .roomThirdPartyInvite, .roomTag, .presence, .typing, .callInvite, .callCandidates, .callAnswer, .callSelectAnswer, .callHangup, .callReject, .callNegotiate, .callReplaces, .callRejectReplacement, .callAssertedIdentity, .callAssertedIdentityUnstable, .reaction, .receipt, .roomTombStone, .keyVerificationStart, .keyVerificationAccept, .keyVerificationKey, .keyVerificationMac, .keyVerificationCancel, .keyVerificationDone, .taggedEvents, .spaceChild, .pollStart, .pollResponse, .pollEnd]
let events: [MXEventType] = [.roomName, .roomTopic, .roomAvatar, .roomMember, .roomCreate, .roomJoinRules, .roomPowerLevels, .roomAliases, .roomCanonicalAlias, .roomEncrypted, .roomEncryption, .roomGuestAccess, .roomHistoryVisibility, .roomKey, .roomForwardedKey, .roomKeyRequest, .roomMessage, .roomMessageFeedback, .roomRedaction, .roomThirdPartyInvite, .roomTag, .presence, .typing, .callInvite, .callCandidates, .callAnswer, .callSelectAnswer, .callHangup, .callReject, .callNegotiate, .callReplaces, .callRejectReplacement, .callAssertedIdentity, .callAssertedIdentityUnstable, .reaction, .receipt, .roomTombStone, .keyVerificationStart, .keyVerificationAccept, .keyVerificationKey, .keyVerificationMac, .keyVerificationCancel, .keyVerificationDone, .taggedEvents, .spaceChild, .spaceOrder, .pollStart, .pollResponse, .pollEnd]

if let type = events.first(where: { $0.identifier == identifier }) {
self = type
Expand All @@ -151,6 +153,8 @@ public enum MXEventType: Equatable, Hashable {
self = .pollResponse
} else if identifier == kMXEventTypeStringPollEnd {
self = .pollEnd
} else if identifier == kMXEventTypeStringSpaceOrder {
self = .spaceOrder
} else {
self = .custom(identifier)
}
Expand Down
6 changes: 6 additions & 0 deletions MatrixSDK/Data/MXRoomAccountData.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
*/
@property (nonatomic, readonly) MXVirtualRoomInfo *virtualRoomInfo;

/**
Space as order as per [MSC3230](https://github.com/matrix-org/matrix-spec-proposals/pull/3230)
*/
@property (nonatomic, readonly, nullable) NSString *spaceOrder;


/**
Process an event that modifies room account data (like m.tag event).
Expand Down
30 changes: 30 additions & 0 deletions MatrixSDK/Data/MXRoomAccountData.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ @interface MXRoomAccountData ()

@property (nonatomic, readwrite) MXVirtualRoomInfo *virtualRoomInfo;

@property (nonatomic, readonly) NSDictionary <NSString*, NSDictionary<NSString*, id> * > *customEvents;

@end

@implementation MXRoomAccountData
Expand Down Expand Up @@ -50,6 +52,17 @@ - (void)handleEvent:(MXEvent *)event
{
self.virtualRoomInfo = [MXVirtualRoomInfo modelFromJSON:event.content];
}
else
{
if (!_customEvents)
{
_customEvents = [NSDictionary new];
}

NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:_customEvents];
dict[event.type] = event.content;
_customEvents = dict;
}
break;
}

Expand All @@ -71,6 +84,18 @@ - (MXTaggedEventInfo*)getTaggedEventInfo:(NSString*)eventId
return _taggedEvents.tags[tag].allKeys;
}

#pragma mark - Properties

- (NSString *)spaceOrder
{
NSString *spaceOrder = nil;
MXJSONModelSetString(spaceOrder, _customEvents[kMXEventTypeStringSpaceOrder][kMXEventTypeStringSpaceOrderKey])
if (!spaceOrder) {
MXJSONModelSetString(spaceOrder, _customEvents[kMXEventTypeStringSpaceOrderMSC3230][kMXEventTypeStringSpaceOrderKey])
}
return spaceOrder;
}

#pragma mark - NSCoding
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
Expand All @@ -81,6 +106,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder
_readMarkerEventId = [aDecoder decodeObjectForKey:@"readMarkerEventId"];
_taggedEvents = [aDecoder decodeObjectForKey:@"taggedEvents"];
_virtualRoomInfo = [MXVirtualRoomInfo modelFromJSON:[aDecoder decodeObjectForKey:@"virtualRoomInfo"]];
_customEvents = [aDecoder decodeObjectForKey:@"customEvents"];
}
return self;
}
Expand All @@ -91,6 +117,10 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
[aCoder encodeObject:_readMarkerEventId forKey:@"readMarkerEventId"];
[aCoder encodeObject:_taggedEvents forKey:@"taggedEvents"];
[aCoder encodeObject:_virtualRoomInfo.JSONDictionary forKey:@"virtualRoomInfo"];
if (_customEvents)
{
[aCoder encodeObject:_customEvents forKey:@"customEvents"];
}
}

@end
2 changes: 1 addition & 1 deletion MatrixSDK/Data/Store/MXFileStore/MXFileStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#import "MatrixSDKSwiftHeader.h"
#import "MXFileRoomSummaryStore.h"

static NSUInteger const kMXFileVersion = 78;
static NSUInteger const kMXFileVersion = 79;

static NSString *const kMXFileStoreFolder = @"MXFileStore";
static NSString *const kMXFileStoreMedaDataFile = @"MXFileStore";
Expand Down
4 changes: 4 additions & 0 deletions MatrixSDK/JSONModels/MXEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ typedef NS_ENUM(NSInteger, MXEventType)
MXEventTypePollStart,
MXEventTypePollResponse,
MXEventTypePollEnd,
MXEventTypeSpaceOrder,

// The event is a custom event. Refer to its `MXEventTypeString` version
MXEventTypeCustom = 1000
Expand Down Expand Up @@ -153,6 +154,9 @@ FOUNDATION_EXPORT NSString *const kMXEventTypeStringSticker;
FOUNDATION_EXPORT NSString *const kMXEventTypeStringRoomTombStone;
FOUNDATION_EXPORT NSString *const kMXEventTypeStringTaggedEvents;
FOUNDATION_EXPORT NSString *const kMXEventTypeStringSpaceChild;
FOUNDATION_EXPORT NSString *const kMXEventTypeStringSpaceOrder;
FOUNDATION_EXPORT NSString *const kMXEventTypeStringSpaceOrderMSC3230;
FOUNDATION_EXPORT NSString *const kMXEventTypeStringSpaceOrderKey;

// Interactive key verification
FOUNDATION_EXPORT NSString *const kMXEventTypeStringKeyVerificationRequest;
Expand Down
3 changes: 3 additions & 0 deletions MatrixSDK/JSONModels/MXEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
NSString *const kMXEventTypeStringSecretStorageDefaultKey = @"m.secret_storage.default_key";
NSString *const kMXEventTypeStringTaggedEvents = @"m.tagged_events";
NSString *const kMXEventTypeStringSpaceChild = @"m.space.child";
NSString *const kMXEventTypeStringSpaceOrder = @"m.space_order";
NSString *const kMXEventTypeStringSpaceOrderMSC3230 = @"org.matrix.msc3230.space_order";
NSString *const kMXEventTypeStringSpaceOrderKey = @"order";

NSString *const kMXEventTypeStringAutoJoinKey = @"auto_join";
NSString *const kMXEventTypeStringSuggestedKey = @"suggested";
Expand Down
4 changes: 2 additions & 2 deletions MatrixSDK/MXRestClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -5926,8 +5926,8 @@ - (MXHTTPOperation*)getSpaceChildrenForSpaceWithId:(NSString*)spaceId
NSString *limitParam = limit >= 0 ? [NSString stringWithFormat:@"&limit=%ld", (long)limit] : @"";
NSString *maxDepthParam = maxDepth >= 0 ? [NSString stringWithFormat:@"&max_depth=%ld", (long)maxDepth] : @"";
NSString *fromParam = paginationToken != nil ? [NSString stringWithFormat:@"&from=%@", paginationToken] : @"";
NSString *path = [NSString stringWithFormat:@"%@/org.matrix.msc2946/rooms/%@/hierarchy?suggested_only=%@%@%@%@",
kMXAPIPrefixPathUnstable, spaceId, suggestedOnly ? @"true": @"false", limitParam, maxDepthParam, fromParam];
NSString *path = [NSString stringWithFormat:@"%@/rooms/%@/hierarchy?suggested_only=%@%@%@%@",
kMXAPIPrefixPathV1, spaceId, suggestedOnly ? @"true": @"false", limitParam, maxDepthParam, fromParam];

MXWeakify(self);
return [httpClient requestWithMethod:@"GET"
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.23.0";
NSString *const MatrixSDKVersion = @"0.23.1";
3 changes: 3 additions & 0 deletions MatrixSDK/Space/MXSpace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class MXSpace: NSObject {
public private(set) var childRoomIds: [String] = []
public private(set) var otherMembersId: [String] = []
public private(set) var suggestedRoomIds: Set<String> = Set()
public var order: String? {
return self.session.store.accountData?(ofRoom: self.spaceId)?.spaceOrder
}

private let processingQueue: DispatchQueue
private let sdkProcessingQueue: DispatchQueue
Expand Down
15 changes: 15 additions & 0 deletions MatrixSDK/Space/MXSpaceService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,21 @@ public class MXSpaceService: NSObject {

let rootSpaces = result.spaces.filter { space in
return parentIdsPerRoomId[space.spaceId] == nil
}.sorted { space1, space2 in
let _space1Order = space1.order
let _space2Order = space2.order

if let space1Order = _space1Order, let space2Order = _space2Order {
return space1Order <= space2Order
}

if _space1Order == nil && _space2Order == nil {
return space1.spaceId <= space2.spaceId
} else if _space1Order != nil && _space2Order == nil {
return true
} else {
return false
}
}

var ancestorsPerRoomId: [String: Set<String>] = [:]
Expand Down

0 comments on commit f041bdc

Please sign in to comment.