Skip to content

Commit

Permalink
Merge branch 'release/0.20.3/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
manuroe committed Sep 28, 2021
2 parents 3a5a4d3 + 6e09550 commit 64be2db
Show file tree
Hide file tree
Showing 15 changed files with 272 additions and 121 deletions.
17 changes: 17 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## Changes in 0.20.3 (2021-09-28)

🙌 Improvements

- Renaming DM rooms to [User Name](Left) after the only other participant leaves. ([#4717](https://github.com/vector-im/element-ios/issues/4717))

🐛 Bugfixes

- MXSpaceService: fixed crash in MXSpaceService.prepareData ([#4910](https://github.com/vector-im/element-ios/issues/4910))
- MXSession: Make `directRooms` property atomic and copying. ([#4911](https://github.com/vector-im/element-ios/issues/4911))
- MXSpaceNotificationCounter: fixed crash in MXSpaceNotificationCounter.isRoomMentionsOnly. ([#4912](https://github.com/vector-im/element-ios/issues/4912))
- MXRoom: fixed crash in MXRoom.toSpace() ([#4913](https://github.com/vector-im/element-ios/issues/4913))
- MXSession: Allow pausing on syncInProgress state. ([#4915](https://github.com/vector-im/element-ios/issues/4915))
- fixed Spaces still visible after logging in with another account ([#4916](https://github.com/vector-im/element-ios/issues/4916))
- MXSpaceService: fixed App may not start in 1.6.0 ([#4919](https://github.com/vector-im/element-ios/issues/4919))


## Changes in 0.20.2 (2021-09-24)

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

s.description = <<-DESC
Expand Down
6 changes: 6 additions & 0 deletions MatrixSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,8 @@
ECBF658626DE3DF800AA3A99 /* MXFileRoomOutgoingMessagesStore.h in Headers */ = {isa = PBXBuildFile; fileRef = ECBF658326DE3DF800AA3A99 /* MXFileRoomOutgoingMessagesStore.h */; };
ECBF658726DE3DF800AA3A99 /* MXFileRoomOutgoingMessagesStore.m in Sources */ = {isa = PBXBuildFile; fileRef = ECBF658426DE3DF800AA3A99 /* MXFileRoomOutgoingMessagesStore.m */; };
ECBF658826DE3DF800AA3A99 /* MXFileRoomOutgoingMessagesStore.m in Sources */ = {isa = PBXBuildFile; fileRef = ECBF658426DE3DF800AA3A99 /* MXFileRoomOutgoingMessagesStore.m */; };
ECD289C42701DADB00F268CF /* MXTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECD289C32701DADA00F268CF /* MXTools.swift */; };
ECD289C52701DADB00F268CF /* MXTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECD289C32701DADA00F268CF /* MXTools.swift */; };
ECD623FF25D3DCC900DC0A0B /* MXOlmDecryption.h in Headers */ = {isa = PBXBuildFile; fileRef = 327187831DA7D0220071C818 /* MXOlmDecryption.h */; settings = {ATTRIBUTES = (Public, ); }; };
ECF29BCC264194AE0053E6D6 /* MXCallAssertedIdentityEventContent.h in Headers */ = {isa = PBXBuildFile; fileRef = ECF29BCB264194AE0053E6D6 /* MXCallAssertedIdentityEventContent.h */; settings = {ATTRIBUTES = (Public, ); }; };
ECF29BCD264194AE0053E6D6 /* MXCallAssertedIdentityEventContent.h in Headers */ = {isa = PBXBuildFile; fileRef = ECF29BCB264194AE0053E6D6 /* MXCallAssertedIdentityEventContent.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -2359,6 +2361,7 @@
ECBF658026DE2A8500AA3A99 /* MXMemoryRoomOutgoingMessagesStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXMemoryRoomOutgoingMessagesStore.m; sourceTree = "<group>"; };
ECBF658326DE3DF800AA3A99 /* MXFileRoomOutgoingMessagesStore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXFileRoomOutgoingMessagesStore.h; sourceTree = "<group>"; };
ECBF658426DE3DF800AA3A99 /* MXFileRoomOutgoingMessagesStore.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXFileRoomOutgoingMessagesStore.m; sourceTree = "<group>"; };
ECD289C32701DADA00F268CF /* MXTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXTools.swift; sourceTree = "<group>"; };
ECF29BCB264194AE0053E6D6 /* MXCallAssertedIdentityEventContent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXCallAssertedIdentityEventContent.h; sourceTree = "<group>"; };
ECF29BD2264194BB0053E6D6 /* MXCallAssertedIdentityEventContent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCallAssertedIdentityEventContent.m; sourceTree = "<group>"; };
ECF29BDD264195320053E6D6 /* MXAssertedIdentityModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXAssertedIdentityModel.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2599,6 +2602,7 @@
32A9F8DD244720B10069C65B /* MXThrottler.m */,
329FB1771A0A74B100A5E88E /* MXTools.h */,
329FB1781A0A74B100A5E88E /* MXTools.m */,
ECD289C32701DADA00F268CF /* MXTools.swift */,
3251D41E25AF01D7001E6E77 /* MXUIKitApplicationStateService.swift */,
32A9E8221EF4026E0081358A /* MXUIKitBackgroundModeHandler.h */,
32A9E8231EF4026E0081358A /* MXUIKitBackgroundModeHandler.m */,
Expand Down Expand Up @@ -5320,6 +5324,7 @@
323547DD2226FC5700F15F94 /* MXCredentials.m in Sources */,
32FA10CF1FA1C9F700E54233 /* MXOutgoingRoomKeyRequest.m in Sources */,
EC05473625FF8A3C0047ECD7 /* MXVirtualRoomInfo.m in Sources */,
ECD289C42701DADB00F268CF /* MXTools.swift in Sources */,
32322A4C1E575F65005DD155 /* MXAllowedCertificates.m in Sources */,
F03EF5051DF01596009DF592 /* MXLRUCache.m in Sources */,
EC8A53AF25B1BC77004E0802 /* MXCallAnswerEventContent.m in Sources */,
Expand Down Expand Up @@ -5756,6 +5761,7 @@
B19A30A72404257700FB6F35 /* MXQRCodeKeyVerificationStart.m in Sources */,
B14EF25A2397E90400758AF0 /* MXEnumConstants.m in Sources */,
B14EF25B2397E90400758AF0 /* MXSession.m in Sources */,
ECD289C52701DADB00F268CF /* MXTools.swift in Sources */,
B14EF25C2397E90400758AF0 /* MXRoomTombStoneContent.m in Sources */,
B14EF25D2397E90400758AF0 /* MXImage.swift in Sources */,
B14EF25E2397E90400758AF0 /* (null) in Sources */,
Expand Down
46 changes: 46 additions & 0 deletions MatrixSDK/Contrib/Swift/MXEnumConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,49 @@ public enum MXTimelineDirection: Equatable, Hashable {
}
}

extension MXSessionState: CustomStringConvertible {

public var description: String {
switch self {
case .closed:
return "closed"
case .initialised:
return "initialized"
case .storeDataReady:
return "storeDataReady"
case .processingBackgroundSyncCache:
return "processingBackgroundSyncCache"
case .syncInProgress:
return "syncInProgress"
case .backgroundSyncInProgress:
return "backgroundSyncInProgress"
case .running:
return "running"
case .homeserverNotReachable:
return "homeserverNotReachable"
case .syncError:
return "syncError"
case .paused:
return "paused"
case .pauseRequested:
return "pauseRequested"
case .initialSyncFailed:
return "initialSyncFailed"
case .unknownToken:
return "unknownToken"
case .softLogout:
return "softLogout"
@unknown default:
return "\(self.rawValue)"
}
}

}

extension MXSessionState: CustomDebugStringConvertible {

public var debugDescription: String {
return description
}

}
4 changes: 0 additions & 4 deletions MatrixSDK/Data/MXRoomNameDefaultStringLocalizations.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,4 @@
*/
@interface MXRoomNameDefaultStringLocalizations : NSObject<MXRoomNameStringsLocalizable>

@property (copy, readonly, nonnull) NSString *emptyRoom;
@property (copy, readonly, nonnull) NSString *twoMembers;
@property (copy, readonly, nonnull) NSString *moreThanTwoMembers;

@end
14 changes: 12 additions & 2 deletions MatrixSDK/Data/MXRoomNameDefaultStringLocalizations.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@

#import "MXRoomNameDefaultStringLocalizations.h"

@interface MXRoomNameDefaultStringLocalizations ()

@property (nonatomic, copy) NSString *emptyRoom;
@property (nonatomic, copy) NSString *twoMembers;
@property (nonatomic, copy) NSString *moreThanTwoMembers;
@property (nonatomic, copy) NSString *allOtherParticipantsLeft;

@end

@implementation MXRoomNameDefaultStringLocalizations

- (instancetype)init
{
self = [super init];
if (self)
if (self == [super init])
{
_emptyRoom = @"Empty room";
_twoMembers = @"%@ and %@";
_moreThanTwoMembers = @"%@ & %@ others";
_allOtherParticipantsLeft = @"%@ (Left)";

}
return self;
}
Expand Down
3 changes: 1 addition & 2 deletions MatrixSDK/Data/MXRoomNameStringsLocalizable.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
*/
@protocol MXRoomNameStringsLocalizable <NSObject>

@required

@property (copy, readonly, nonnull) NSString *emptyRoom;
@property (copy, readonly, nonnull) NSString *twoMembers;
@property (copy, readonly, nonnull) NSString *moreThanTwoMembers;
@property (copy, readonly, nonnull) NSString *allOtherParticipantsLeft;

@end

90 changes: 49 additions & 41 deletions MatrixSDK/Data/MXRoomSummaryUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ - (BOOL)updateSummaryDisplayname:(MXRoomSummary *)summary session:(MXSession *)s

- (BOOL)updateSummaryDisplayname:(MXRoomSummary *)summary session:(MXSession *)session withServerRoomSummary:(MXRoomSyncSummary *)serverRoomSummary roomState:(MXRoomState *)roomState excludingUserIDs:(NSArray<NSString *> *)excludedUserIDs
{
NSString *displayname;
NSString *displayName;

if (!_roomNameStringLocalizations)
{
Expand All @@ -357,109 +357,112 @@ - (BOOL)updateSummaryDisplayname:(MXRoomSummary *)summary session:(MXSession *)s
// If m.room.name is set, use that
if (roomState.name.length)
{
displayname = roomState.name;
displayName = roomState.name;
}
// If m.room.canonical_alias is set, use that
// Note: a "" for canonicalAlias means the previous one has been removed
else if (roomState.canonicalAlias.length)
{
displayname = roomState.canonicalAlias;
displayName = roomState.canonicalAlias;
}
// If the room has an alias, use that
else if (roomState.aliases.count)
{
displayname = roomState.aliases.firstObject;
displayName = roomState.aliases.firstObject;
}
else
{
NSUInteger memberCount = 0;
NSMutableArray<NSString*> *memberNames;
NSMutableArray<NSString*> *memberIdentifiers = [NSMutableArray array];

// Use Matrix room summaries and heroes
if (serverRoomSummary)
{
memberCount = serverRoomSummary.joinedMemberCount + serverRoomSummary.invitedMemberCount;

if (serverRoomSummary.heroes.count)
{
memberNames = [NSMutableArray arrayWithCapacity:serverRoomSummary.heroes.count];
for (NSString *hero in serverRoomSummary.heroes)
{
if ([excludedUserIDs containsObject:hero])
{
continue;
}

NSString *memberName = [roomState.members memberName:hero];
if (!memberName)
{
memberName = hero;
}

[memberNames addObject:memberName];
[memberIdentifiers addObject:hero];
}
}

memberCount = serverRoomSummary.joinedMemberCount + serverRoomSummary.invitedMemberCount;
}
// Or in case of non lazy loading and no server room summary,
// use the full room state
else if (roomState.membersCount.members > 1)
{
NSArray *otherMembers = [self sortedOtherMembersInRoomState:roomState withMatrixSession:session];

memberNames = [NSMutableArray arrayWithCapacity:otherMembers.count];
for (MXRoomMember *member in otherMembers)
{
if ([excludedUserIDs containsObject:member.userId])
{
continue;
}

NSString *memberName = [roomState.members memberName:member.userId];
if (memberName)
{
[memberNames addObject:memberName];
}
[memberIdentifiers addObject:member.userId];
}

memberCount = memberNames.count + 1;
memberCount = memberIdentifiers.count + 1;
}

// We display 2 users names max. Then, for larger rooms, we display "Alice and X others"
switch (memberNames.count)
switch (memberIdentifiers.count)
{
case 0:
displayname = _roomNameStringLocalizations.emptyRoom;
{
displayName = _roomNameStringLocalizations.emptyRoom;
break;

}
case 1:
displayname = memberNames.firstObject;
{
MXRoomMember *member = [roomState.members memberWithUserId:memberIdentifiers.firstObject];
NSString *memberName = [self memberNameFromRoomState:roomState withIdentifier:memberIdentifiers.firstObject];

if (member.membership == MXMembershipLeave)
{
displayName = [NSString stringWithFormat:_roomNameStringLocalizations.allOtherParticipantsLeft, memberName];
}
else
{
displayName = memberName;
}
break;

}
case 2:
displayname = [NSString stringWithFormat:_roomNameStringLocalizations.twoMembers,
memberNames[0],
memberNames[1]];
{
NSString *firstMemberName = [self memberNameFromRoomState:roomState withIdentifier:memberIdentifiers[0]];
NSString *secondMemberName = [self memberNameFromRoomState:roomState withIdentifier:memberIdentifiers[1]];
displayName = [NSString stringWithFormat:_roomNameStringLocalizations.twoMembers, firstMemberName, secondMemberName];
break;

}
default:
displayname = [NSString stringWithFormat:_roomNameStringLocalizations.moreThanTwoMembers,
memberNames[0],
@(memberCount - 2)];
{
NSString *memberName = [self memberNameFromRoomState:roomState withIdentifier:memberIdentifiers.firstObject];
displayName = [NSString stringWithFormat:_roomNameStringLocalizations.moreThanTwoMembers,
memberName,
@(memberCount - 2)];
break;
}
}

if (memberCount > 1
&& (!displayname || [displayname isEqualToString:_roomNameStringLocalizations.emptyRoom]))
&& (!displayName || [displayName isEqualToString:_roomNameStringLocalizations.emptyRoom]))
{
// Data are missing to compute the display name
MXLogDebug(@"[MXRoomSummaryUpdater] updateSummaryDisplayname: Warning: Computed an unexpected \"Empty Room\" name. memberCount: %@", @(memberCount));
displayname = [self fixUnexpectedEmptyRoomDisplayname:memberCount session:session roomState:roomState];
displayName = [self fixUnexpectedEmptyRoomDisplayname:memberCount session:session roomState:roomState];
}
}

if (displayname != summary.displayname || ![displayname isEqualToString:summary.displayname])
if (displayName != summary.displayname || ![displayName isEqualToString:summary.displayname])
{
summary.displayname = displayname;
summary.displayname = displayName;
return YES;
}

Expand Down Expand Up @@ -714,5 +717,10 @@ - (BOOL)shouldHideRoomWithRoomTypeString:(NSString*)roomTypeString
return hiddenFromUser;
}

- (NSString *)memberNameFromRoomState:(MXRoomState *)roomState withIdentifier:(NSString *)identifier
{
NSString *name = [roomState.members memberName:identifier];
return (name.length > 0 ? name : identifier);
}

@end
2 changes: 1 addition & 1 deletion MatrixSDK/MXSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ typedef void (^MXOnBackgroundSyncFail)(NSError *error);
A dictionary where the keys are the user IDs and values are lists of room ID strings.
*/
@property (nonatomic, readonly) NSDictionary<NSString*, NSArray<NSString*>*> *directRooms;
@property (atomic, copy, readonly) NSDictionary<NSString*, NSArray<NSString*>*> *directRooms;

/**
Return the first joined direct chat listed in account data for this user.
Expand Down
Loading

0 comments on commit 64be2db

Please sign in to comment.