mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
updateMembers now is chain of membersNoSync + membersWithSync (#2324)
This commit is contained in:
@@ -6660,7 +6660,7 @@
|
|||||||
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
|
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = exactVersion;
|
kind = exactVersion;
|
||||||
version = 1.1.31;
|
version = 1.1.32;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = {
|
821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = {
|
||||||
|
|||||||
@@ -130,8 +130,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
|
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "c9c6725af2c9fa93c19f710e307b0b25e0f1fa26",
|
"revision" : "07556e1b475291ec4794e22e9348a5a7db137595",
|
||||||
"version" : "1.1.31"
|
"version" : "1.1.32"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1614,21 +1614,21 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol {
|
|||||||
return getRoomsWithUserDefinedRulesReturnValue
|
return getRoomsWithUserDefinedRulesReturnValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//MARK: - canHomeserverPushEncryptedEventsToDevice
|
//MARK: - canPushEncryptedEventsToDevice
|
||||||
|
|
||||||
var canHomeserverPushEncryptedEventsToDeviceCallsCount = 0
|
var canPushEncryptedEventsToDeviceCallsCount = 0
|
||||||
var canHomeserverPushEncryptedEventsToDeviceCalled: Bool {
|
var canPushEncryptedEventsToDeviceCalled: Bool {
|
||||||
return canHomeserverPushEncryptedEventsToDeviceCallsCount > 0
|
return canPushEncryptedEventsToDeviceCallsCount > 0
|
||||||
}
|
}
|
||||||
var canHomeserverPushEncryptedEventsToDeviceReturnValue: Bool!
|
var canPushEncryptedEventsToDeviceReturnValue: Bool!
|
||||||
var canHomeserverPushEncryptedEventsToDeviceClosure: (() async -> Bool)?
|
var canPushEncryptedEventsToDeviceClosure: (() async -> Bool)?
|
||||||
|
|
||||||
func canHomeserverPushEncryptedEventsToDevice() async -> Bool {
|
func canPushEncryptedEventsToDevice() async -> Bool {
|
||||||
canHomeserverPushEncryptedEventsToDeviceCallsCount += 1
|
canPushEncryptedEventsToDeviceCallsCount += 1
|
||||||
if let canHomeserverPushEncryptedEventsToDeviceClosure = canHomeserverPushEncryptedEventsToDeviceClosure {
|
if let canPushEncryptedEventsToDeviceClosure = canPushEncryptedEventsToDeviceClosure {
|
||||||
return await canHomeserverPushEncryptedEventsToDeviceClosure()
|
return await canPushEncryptedEventsToDeviceClosure()
|
||||||
} else {
|
} else {
|
||||||
return canHomeserverPushEncryptedEventsToDeviceReturnValue
|
return canPushEncryptedEventsToDeviceReturnValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ struct NotificationSettingsProxyMockConfiguration {
|
|||||||
var callback = PassthroughSubject<NotificationSettingsProxyCallback, Never>()
|
var callback = PassthroughSubject<NotificationSettingsProxyCallback, Never>()
|
||||||
var defaultRoomMode: RoomNotificationModeProxy
|
var defaultRoomMode: RoomNotificationModeProxy
|
||||||
var roomMode: RoomNotificationSettingsProxyMock
|
var roomMode: RoomNotificationSettingsProxyMock
|
||||||
var canHomeserverPushEncryptedEvents = false
|
var canPushEncryptedEvents = false
|
||||||
|
|
||||||
init(defaultRoomMode: RoomNotificationModeProxy = .allMessages, roomMode: RoomNotificationModeProxy = .allMessages, canHomeserverPushEncryptedEvents: Bool = false) {
|
init(defaultRoomMode: RoomNotificationModeProxy = .allMessages, roomMode: RoomNotificationModeProxy = .allMessages, canPushEncryptedEvents: Bool = false) {
|
||||||
self.defaultRoomMode = defaultRoomMode
|
self.defaultRoomMode = defaultRoomMode
|
||||||
self.roomMode = RoomNotificationSettingsProxyMock(with: RoomNotificationSettingsProxyMockConfiguration(mode: roomMode, isDefault: defaultRoomMode == roomMode))
|
self.roomMode = RoomNotificationSettingsProxyMock(with: RoomNotificationSettingsProxyMockConfiguration(mode: roomMode, isDefault: defaultRoomMode == roomMode))
|
||||||
self.canHomeserverPushEncryptedEvents = canHomeserverPushEncryptedEvents
|
self.canPushEncryptedEvents = canPushEncryptedEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,8 +92,8 @@ extension NotificationSettingsProxyMock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
canHomeserverPushEncryptedEventsToDeviceClosure = {
|
canPushEncryptedEventsToDeviceClosure = {
|
||||||
configuration.canHomeserverPushEncryptedEvents
|
configuration.canPushEncryptedEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -84,7 +84,7 @@ class RoomNotificationSettingsScreenViewModel: RoomNotificationSettingsScreenVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func fetchRoomNotificationSettings() async {
|
private func fetchRoomNotificationSettings() async {
|
||||||
state.shouldDisplayMentionsOnlyDisclaimer = roomProxy.isEncrypted ? await !notificationSettingsProxy.canHomeserverPushEncryptedEventsToDevice() : false
|
state.shouldDisplayMentionsOnlyDisclaimer = roomProxy.isEncrypted ? await !notificationSettingsProxy.canPushEncryptedEventsToDevice() : false
|
||||||
do {
|
do {
|
||||||
// `isOneToOne` here is not the same as `isDirect` on the room. From the point of view of the push rule, a one-to-one room is a room with exactly two active members.
|
// `isOneToOne` here is not the same as `isDirect` on the room. From the point of view of the push rule, a one-to-one room is a room with exactly two active members.
|
||||||
let settings = try await notificationSettingsProxy.getNotificationSettings(roomId: roomProxy.id,
|
let settings = try await notificationSettingsProxy.getNotificationSettings(roomId: roomProxy.id,
|
||||||
|
|||||||
+2
-2
@@ -33,7 +33,7 @@ struct NotificationSettingsEditScreenViewState: BindableState {
|
|||||||
var defaultMode: NotificationSettingsEditScreenDefaultMode?
|
var defaultMode: NotificationSettingsEditScreenDefaultMode?
|
||||||
var pendingMode: NotificationSettingsEditScreenDefaultMode?
|
var pendingMode: NotificationSettingsEditScreenDefaultMode?
|
||||||
var roomsWithUserDefinedMode: [NotificationSettingsEditScreenRoom] = []
|
var roomsWithUserDefinedMode: [NotificationSettingsEditScreenRoom] = []
|
||||||
var canHomeServerPushEncryptedEvents = false
|
var canPushEncryptedEvents = false
|
||||||
|
|
||||||
func isSelected(mode: NotificationSettingsEditScreenDefaultMode) -> Bool {
|
func isSelected(mode: NotificationSettingsEditScreenDefaultMode) -> Bool {
|
||||||
pendingMode == nil && defaultMode == mode
|
pendingMode == nil && defaultMode == mode
|
||||||
@@ -41,7 +41,7 @@ struct NotificationSettingsEditScreenViewState: BindableState {
|
|||||||
|
|
||||||
func description(for mode: NotificationSettingsEditScreenDefaultMode) -> String? {
|
func description(for mode: NotificationSettingsEditScreenDefaultMode) -> String? {
|
||||||
guard mode == .mentionsAndKeywordsOnly,
|
guard mode == .mentionsAndKeywordsOnly,
|
||||||
!canHomeServerPushEncryptedEvents else {
|
!canPushEncryptedEvents else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return L10n.screenNotificationSettingsMentionsOnlyDisclaimer
|
return L10n.screenNotificationSettingsMentionsOnlyDisclaimer
|
||||||
|
|||||||
+2
-2
@@ -93,7 +93,7 @@ class NotificationSettingsEditScreenViewModel: NotificationSettingsEditScreenVie
|
|||||||
if encrypted_mode == unencrypted_mode {
|
if encrypted_mode == unencrypted_mode {
|
||||||
mode = encrypted_mode
|
mode = encrypted_mode
|
||||||
}
|
}
|
||||||
let canHomserverPushEncryptedEvents = await notificationSettingsProxy.canHomeserverPushEncryptedEventsToDevice()
|
let canPushEncryptedEvents = await notificationSettingsProxy.canPushEncryptedEventsToDevice()
|
||||||
guard !Task.isCancelled else { return }
|
guard !Task.isCancelled else { return }
|
||||||
|
|
||||||
switch mode {
|
switch mode {
|
||||||
@@ -104,7 +104,7 @@ class NotificationSettingsEditScreenViewModel: NotificationSettingsEditScreenVie
|
|||||||
default:
|
default:
|
||||||
state.defaultMode = nil
|
state.defaultMode = nil
|
||||||
}
|
}
|
||||||
state.canHomeServerPushEncryptedEvents = canHomserverPushEncryptedEvents
|
state.canPushEncryptedEvents = canPushEncryptedEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -114,7 +114,7 @@ struct NotificationSettingsEditScreen_Previews: PreviewProvider, TestablePreview
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
static let viewModelGroupChatsWithouDisclaimer: NotificationSettingsEditScreenViewModel = {
|
static let viewModelGroupChatsWithouDisclaimer: NotificationSettingsEditScreenViewModel = {
|
||||||
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init(canHomeserverPushEncryptedEvents: true))
|
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init(canPushEncryptedEvents: true))
|
||||||
notificationSettingsProxy.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue = .allMessages
|
notificationSettingsProxy.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue = .allMessages
|
||||||
|
|
||||||
notificationSettingsProxy.getRoomsWithUserDefinedRulesReturnValue = [RoomSummary].mockRooms.compactMap(\.id)
|
notificationSettingsProxy.getRoomsWithUserDefinedRulesReturnValue = [RoomSummary].mockRooms.compactMap(\.id)
|
||||||
|
|||||||
@@ -141,8 +141,8 @@ final class NotificationSettingsProxy: NotificationSettingsProxyProtocol {
|
|||||||
await notificationSettings.getRoomsWithUserDefinedRules(enabled: true)
|
await notificationSettings.getRoomsWithUserDefinedRules(enabled: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func canHomeserverPushEncryptedEventsToDevice() async -> Bool {
|
func canPushEncryptedEventsToDevice() async -> Bool {
|
||||||
await notificationSettings.canHomeserverPushEncryptedEventToDevice()
|
await notificationSettings.canPushEncryptedEventToDevice()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|||||||
+1
-1
@@ -40,5 +40,5 @@ protocol NotificationSettingsProxyProtocol {
|
|||||||
func isInviteForMeEnabled() async throws -> Bool
|
func isInviteForMeEnabled() async throws -> Bool
|
||||||
func setInviteForMeEnabled(enabled: Bool) async throws
|
func setInviteForMeEnabled(enabled: Bool) async throws
|
||||||
func getRoomsWithUserDefinedRules() async throws -> [String]
|
func getRoomsWithUserDefinedRules() async throws -> [String]
|
||||||
func canHomeserverPushEncryptedEventsToDevice() async -> Bool
|
func canPushEncryptedEventsToDevice() async -> Bool
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,10 +65,6 @@ class RoomProxy: RoomProxyProtocol {
|
|||||||
pollHistoryTimeline = await TimelineProxy(timeline: room.pollHistory(), backgroundTaskService: backgroundTaskService)
|
pollHistoryTimeline = await TimelineProxy(timeline: room.pollHistory(), backgroundTaskService: backgroundTaskService)
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
// Force the timeline to load member details so it can populate sender profiles whenever we add a timeline listener
|
|
||||||
// This should become automatic on the RustSDK side at some point
|
|
||||||
await room.timeline().fetchMembers()
|
|
||||||
|
|
||||||
await updateMembers()
|
await updateMembers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,21 +175,31 @@ class RoomProxy: RoomProxyProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateMembers() async {
|
func updateMembers() async {
|
||||||
|
// We always update members first using the no sync API in case internet is not readily available
|
||||||
|
// To get the members stored on disk first, this API call is very fast.
|
||||||
do {
|
do {
|
||||||
let membersIterator = try await room.members()
|
let membersNoSyncIterator = try await room.membersNoSync()
|
||||||
guard let members = membersIterator.nextChunk(chunkSize: membersIterator.len()) else {
|
if let members = membersNoSyncIterator.nextChunk(chunkSize: membersNoSyncIterator.len()) {
|
||||||
return
|
membersSubject.value = members.map {
|
||||||
|
RoomMemberProxy(member: $0, backgroundTaskService: self.backgroundTaskService)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let roomMembersProxies = members.map {
|
|
||||||
RoomMemberProxy(member: $0, backgroundTaskService: self.backgroundTaskService)
|
|
||||||
}
|
|
||||||
|
|
||||||
membersSubject.value = roomMembersProxies
|
|
||||||
} catch {
|
} catch {
|
||||||
return
|
MXLog.error("[RoomProxy] Failed to update members using no sync API: \(error)")
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
// Then we update members using the sync API, this is slower but will get us the latest members
|
||||||
|
let membersIterator = try await room.members()
|
||||||
|
if let members = membersIterator.nextChunk(chunkSize: membersIterator.len()) {
|
||||||
|
membersSubject.value = members.map {
|
||||||
|
RoomMemberProxy(member: $0, backgroundTaskService: self.backgroundTaskService)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
MXLog.error("[RoomProxy] Failed to update members using sync API: \(error)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class NotificationSettingsEditScreenViewModelTests: XCTestCase {
|
|||||||
|
|
||||||
XCTAssertEqual(context.viewState.defaultMode, .mentionsAndKeywordsOnly)
|
XCTAssertEqual(context.viewState.defaultMode, .mentionsAndKeywordsOnly)
|
||||||
XCTAssertNil(context.viewState.bindings.alertInfo)
|
XCTAssertNil(context.viewState.bindings.alertInfo)
|
||||||
XCTAssertFalse(context.viewState.canHomeServerPushEncryptedEvents)
|
XCTAssertFalse(context.viewState.canPushEncryptedEvents)
|
||||||
XCTAssertNotNil(context.viewState.description(for: .mentionsAndKeywordsOnly))
|
XCTAssertNotNil(context.viewState.description(for: .mentionsAndKeywordsOnly))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ class NotificationSettingsEditScreenViewModelTests: XCTestCase {
|
|||||||
return .mentionsAndKeywordsOnly
|
return .mentionsAndKeywordsOnly
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notificationSettingsProxy.canHomeserverPushEncryptedEventsToDeviceClosure = {
|
notificationSettingsProxy.canPushEncryptedEventsToDeviceClosure = {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
viewModel = NotificationSettingsEditScreenViewModel(chatType: .groupChat,
|
viewModel = NotificationSettingsEditScreenViewModel(chatType: .groupChat,
|
||||||
@@ -113,7 +113,7 @@ class NotificationSettingsEditScreenViewModelTests: XCTestCase {
|
|||||||
|
|
||||||
XCTAssertEqual(context.viewState.defaultMode, .mentionsAndKeywordsOnly)
|
XCTAssertEqual(context.viewState.defaultMode, .mentionsAndKeywordsOnly)
|
||||||
XCTAssertNil(context.viewState.bindings.alertInfo)
|
XCTAssertNil(context.viewState.bindings.alertInfo)
|
||||||
XCTAssertTrue(context.viewState.canHomeServerPushEncryptedEvents)
|
XCTAssertTrue(context.viewState.canPushEncryptedEvents)
|
||||||
XCTAssertNil(context.viewState.description(for: .mentionsAndKeywordsOnly))
|
XCTAssertNil(context.viewState.description(for: .mentionsAndKeywordsOnly))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class RoomNotificationSettingsScreenViewModelTests: XCTestCase {
|
|||||||
|
|
||||||
func testInitialStateDefaultModeEncryptedRoomWithCanPushEncrypted() async throws {
|
func testInitialStateDefaultModeEncryptedRoomWithCanPushEncrypted() async throws {
|
||||||
let roomProxyMock = RoomProxyMock(with: .init(displayName: "Test", isEncrypted: true, joinedMembersCount: 0))
|
let roomProxyMock = RoomProxyMock(with: .init(displayName: "Test", isEncrypted: true, joinedMembersCount: 0))
|
||||||
let notificationSettingsProxyMock = NotificationSettingsProxyMock(with: .init(canHomeserverPushEncryptedEvents: true))
|
let notificationSettingsProxyMock = NotificationSettingsProxyMock(with: .init(canPushEncryptedEvents: true))
|
||||||
|
|
||||||
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: true))
|
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: true))
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Fix for read receipts loading slowly when opening a room.
|
||||||
+1
-1
@@ -47,7 +47,7 @@ packages:
|
|||||||
# Element/Matrix dependencies
|
# Element/Matrix dependencies
|
||||||
MatrixRustSDK:
|
MatrixRustSDK:
|
||||||
url: https://github.com/matrix-org/matrix-rust-components-swift
|
url: https://github.com/matrix-org/matrix-rust-components-swift
|
||||||
exactVersion: 1.1.31
|
exactVersion: 1.1.32
|
||||||
# path: ../matrix-rust-sdk
|
# path: ../matrix-rust-sdk
|
||||||
Compound:
|
Compound:
|
||||||
url: https://github.com/element-hq/compound-ios
|
url: https://github.com/element-hq/compound-ios
|
||||||
|
|||||||
Reference in New Issue
Block a user