Skip to content

Commit

Permalink
Merge branch 'release/0.18.9/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
manuroe committed Apr 16, 2021
2 parents 9bf1052 + 84b4374 commit 39c43b2
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 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.18.9 (2021-04-16)
=================================================

✨ Features
*

🙌 Improvements
*

🐛 Bugfix
* Notifications: Fix sender display name that can miss (vector-im/element-ios/issues/#4222).

⚠️ API Changes
*

🗣 Translations
*

🧱 Build
*

Others
*

Improvements:


Changes in 0.18.8 (2021-04-14)
=================================================

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

s.description = <<-DESC
Expand Down
37 changes: 37 additions & 0 deletions MatrixSDK/Background/MXBackgroundSyncService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public enum MXBackgroundSyncServiceError: Error {
/// Cached events. Keys are even identifiers.
private var cachedEvents: [String: MXEvent] = [:]

/// Cached profiles. UserId -> (displayName, avatarUrl)
private var cachedProfiles: [String: (String?, String?)] = [:]

/// See MXSyncResponseStoreManager.syncResponseCacheSizeLimit
public var syncResponseCacheSizeLimit: Int {
get {
Expand Down Expand Up @@ -131,6 +134,40 @@ public enum MXBackgroundSyncServiceError: Error {
}
}

/// Get the profile of a room member.
///
/// This method must be called when the member is not visible in the room state. It happens in case of
/// lazy loading of room members, not all members are known yet.
///
/// - Parameters:
/// - userId: The user id.
/// - roomId: The room id.
/// - completion: Completion block to be called. Always called in main thread.
public func profile(ofMember userId: String, inRoom roomId: String, completion: @escaping (MXResponse<(String?, String?)>) -> Void) {

// There is no CS API to get a single member in a room. /members will be expensive in a room with thousands of users.
// So, use the simplest possible HS API to get the data, the profile API.
// It will not take into account customised name into the room but that will be better than a Matrix id.

// Check cache first
if let (displayName, avatarUrl) = cachedProfiles[userId] {
Queues.dispatchQueue.async {
completion(.success((displayName, avatarUrl)))
}
return
}

// Else make a request
restClient.profile(forUser: userId) { (response) in
Queues.dispatchQueue.async {
if let (displayName, avatarUrl) = response.value {
self.cachedProfiles[userId] = (displayName, avatarUrl)
}
completion(response)
}
}
}

/// Check whether the given room is mentions only.
/// - Parameter roomId: The room identifier to be checked
/// - Returns: If the room is mentions only.
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.18.8";
NSString *const MatrixSDKVersion = @"0.18.9";

0 comments on commit 39c43b2

Please sign in to comment.