mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Remove the dynamic member lookup from UserSettings in favour of nested access. (#6294)
* Remove the dynamic member lookup from UserSettings in favour of nested access. * Remove forwarding methods from UserSettings. * Update the Enterprise submodule.
This commit is contained in:
@@ -41,11 +41,11 @@ final class LiveLocationManagerTests {
|
||||
|
||||
try result.get()
|
||||
#expect(callOrder == ["stop", "start"])
|
||||
#expect(userSettings.liveLocationSharingSessionsByRoomID["!room:matrix.org"] == nil)
|
||||
#expect(userSettings.app.liveLocationSharingSessionsByRoomID["!room:matrix.org"] == nil)
|
||||
|
||||
try await simulateBeaconEcho(roomID: "!room:matrix.org", eventID: "$event:matrix.org")
|
||||
|
||||
#expect(userSettings.liveLocationSharingSessionsByRoomID["!room:matrix.org"] != nil)
|
||||
#expect(userSettings.app.liveLocationSharingSessionsByRoomID["!room:matrix.org"] != nil)
|
||||
#expect(locationManagerMock.startUpdatingLocationCalled)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ final class LiveLocationManagerTests {
|
||||
setUp()
|
||||
let roomProxy = makeRoomProxy(roomID: "!room:matrix.org")
|
||||
clientProxy.roomForIdentifierClosure = { _ in .joined(roomProxy) }
|
||||
userSettings.liveLocationSharingSessionsByRoomID["!room:matrix.org"] = LiveLocationSession(eventID: "$old_event:matrix.org", expirationDate: Date().addingTimeInterval(300))
|
||||
userSettings.app.liveLocationSharingSessionsByRoomID["!room:matrix.org"] = LiveLocationSession(eventID: "$old_event:matrix.org", expirationDate: Date().addingTimeInterval(300))
|
||||
|
||||
var callOrder: [String] = []
|
||||
roomProxy.stopLiveLocationShareClosure = {
|
||||
@@ -73,7 +73,7 @@ final class LiveLocationManagerTests {
|
||||
|
||||
try await simulateBeaconEcho(roomID: "!room:matrix.org", eventID: "$event:matrix.org")
|
||||
|
||||
#expect(userSettings.liveLocationSharingSessionsByRoomID["!room:matrix.org"] != nil)
|
||||
#expect(userSettings.app.liveLocationSharingSessionsByRoomID["!room:matrix.org"] != nil)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,12 +82,12 @@ final class LiveLocationManagerTests {
|
||||
let roomProxy = makeRoomProxy(roomID: "!room1:matrix.org")
|
||||
clientProxy.roomForIdentifierClosure = { _ in .joined(roomProxy) }
|
||||
|
||||
userSettings.liveLocationSharingSessionsByRoomID["!room2:matrix.org"] = LiveLocationSession(eventID: "$event:matrix.org", expirationDate: Date().addingTimeInterval(300))
|
||||
userSettings.app.liveLocationSharingSessionsByRoomID["!room2:matrix.org"] = LiveLocationSession(eventID: "$event:matrix.org", expirationDate: Date().addingTimeInterval(300))
|
||||
|
||||
_ = await manager.startLiveLocation(roomID: "!room1:matrix.org", duration: .seconds(300))
|
||||
|
||||
#expect(roomProxy.stopLiveLocationShareCalled)
|
||||
#expect(userSettings.liveLocationSharingSessionsByRoomID["!room2:matrix.org"] != nil)
|
||||
#expect(userSettings.app.liveLocationSharingSessionsByRoomID["!room2:matrix.org"] != nil)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,7 +98,7 @@ final class LiveLocationManagerTests {
|
||||
let result = await manager.startLiveLocation(roomID: "!room:matrix.org", duration: .seconds(300))
|
||||
|
||||
#expect(throws: LiveLocationManagerError.roomNotJoined) { try result.get() }
|
||||
#expect(userSettings.liveLocationSharingSessionsByRoomID["!room:matrix.org"] == nil)
|
||||
#expect(userSettings.app.liveLocationSharingSessionsByRoomID["!room:matrix.org"] == nil)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -111,7 +111,7 @@ final class LiveLocationManagerTests {
|
||||
let result = await manager.startLiveLocation(roomID: "!room:matrix.org", duration: .seconds(300))
|
||||
|
||||
#expect(throws: LiveLocationManagerError.startFailed) { try result.get() }
|
||||
#expect(userSettings.liveLocationSharingSessionsByRoomID["!room:matrix.org"] == nil)
|
||||
#expect(userSettings.app.liveLocationSharingSessionsByRoomID["!room:matrix.org"] == nil)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,7 +127,7 @@ final class LiveLocationManagerTests {
|
||||
|
||||
try await simulateBeaconEcho(roomID: "!room:matrix.org", eventID: "$event:matrix.org")
|
||||
|
||||
let storedSession = try #require(userSettings.liveLocationSharingSessionsByRoomID["!room:matrix.org"])
|
||||
let storedSession = try #require(userSettings.app.liveLocationSharingSessionsByRoomID["!room:matrix.org"])
|
||||
let expectedMinTimeout = beforeStart.addingTimeInterval(TimeInterval(duration.seconds))
|
||||
let expectedMaxTimeout = afterStart.addingTimeInterval(TimeInterval(duration.seconds))
|
||||
|
||||
@@ -142,12 +142,12 @@ final class LiveLocationManagerTests {
|
||||
setUp()
|
||||
let roomProxy = makeRoomProxy(roomID: "!room:matrix.org")
|
||||
clientProxy.roomForIdentifierClosure = { _ in .joined(roomProxy) }
|
||||
userSettings.liveLocationSharingSessionsByRoomID["!room:matrix.org"] = LiveLocationSession(eventID: "$event:matrix.org", expirationDate: Date().addingTimeInterval(300))
|
||||
userSettings.app.liveLocationSharingSessionsByRoomID["!room:matrix.org"] = LiveLocationSession(eventID: "$event:matrix.org", expirationDate: Date().addingTimeInterval(300))
|
||||
|
||||
await manager.stopLiveLocation(roomID: "!room:matrix.org")
|
||||
|
||||
#expect(roomProxy.stopLiveLocationShareCalled)
|
||||
#expect(userSettings.liveLocationSharingSessionsByRoomID["!room:matrix.org"] == nil)
|
||||
#expect(userSettings.app.liveLocationSharingSessionsByRoomID["!room:matrix.org"] == nil)
|
||||
// Setting the timeout date above starts tracking; removing it stops tracking.
|
||||
#expect(locationManagerMock.startUpdatingLocationCalled)
|
||||
#expect(locationManagerMock.stopUpdatingLocationCalled)
|
||||
@@ -169,13 +169,13 @@ final class LiveLocationManagerTests {
|
||||
setUp()
|
||||
let roomProxy = makeRoomProxy(roomID: "!room1:matrix.org")
|
||||
clientProxy.roomForIdentifierClosure = { _ in .joined(roomProxy) }
|
||||
userSettings.liveLocationSharingSessionsByRoomID["!room1:matrix.org"] = LiveLocationSession(eventID: "$event:matrix.org", expirationDate: Date().addingTimeInterval(300))
|
||||
userSettings.liveLocationSharingSessionsByRoomID["!room2:matrix.org"] = LiveLocationSession(eventID: "$event:matrix.org", expirationDate: Date().addingTimeInterval(300))
|
||||
userSettings.app.liveLocationSharingSessionsByRoomID["!room1:matrix.org"] = LiveLocationSession(eventID: "$event:matrix.org", expirationDate: Date().addingTimeInterval(300))
|
||||
userSettings.app.liveLocationSharingSessionsByRoomID["!room2:matrix.org"] = LiveLocationSession(eventID: "$event:matrix.org", expirationDate: Date().addingTimeInterval(300))
|
||||
|
||||
await manager.stopLiveLocation(roomID: "!room1:matrix.org")
|
||||
|
||||
#expect(userSettings.liveLocationSharingSessionsByRoomID["!room1:matrix.org"] == nil)
|
||||
#expect(userSettings.liveLocationSharingSessionsByRoomID["!room2:matrix.org"] != nil)
|
||||
#expect(userSettings.app.liveLocationSharingSessionsByRoomID["!room1:matrix.org"] == nil)
|
||||
#expect(userSettings.app.liveLocationSharingSessionsByRoomID["!room2:matrix.org"] != nil)
|
||||
}
|
||||
|
||||
// MARK: - Beacon info updates
|
||||
@@ -188,13 +188,13 @@ final class LiveLocationManagerTests {
|
||||
|
||||
try await manager.startLiveLocation(roomID: "!room:matrix.org", duration: .seconds(300)).get()
|
||||
try await simulateBeaconEcho(roomID: "!room:matrix.org", eventID: "$event:matrix.org")
|
||||
#expect(userSettings.liveLocationSharingSessionsByRoomID["!room:matrix.org"] != nil)
|
||||
#expect(userSettings.app.liveLocationSharingSessionsByRoomID["!room:matrix.org"] != nil)
|
||||
|
||||
let deferred = deferFulfillment(userSettings.liveLocationSharingSessionsByRoomIDPublisher) { $0["!room:matrix.org"] == nil }
|
||||
let deferred = deferFulfillment(userSettings.app.liveLocationSharingSessionsByRoomIDPublisher) { $0["!room:matrix.org"] == nil }
|
||||
beaconInfoSubject.send(LiveLocationOwnInfoUpdate(roomID: "!room:matrix.org", eventID: "$external_event:matrix.org", isLive: true))
|
||||
try await deferred.fulfill()
|
||||
|
||||
#expect(userSettings.liveLocationSharingSessionsByRoomID["!room:matrix.org"] == nil)
|
||||
#expect(userSettings.app.liveLocationSharingSessionsByRoomID["!room:matrix.org"] == nil)
|
||||
}
|
||||
|
||||
// MARK: - Reduced accuracy
|
||||
@@ -237,7 +237,7 @@ final class LiveLocationManagerTests {
|
||||
}
|
||||
|
||||
private func simulateBeaconEcho(roomID: String, eventID: String) async throws {
|
||||
let deferred = deferFulfillment(userSettings.liveLocationSharingSessionsByRoomIDPublisher) { $0[roomID] != nil }
|
||||
let deferred = deferFulfillment(userSettings.app.liveLocationSharingSessionsByRoomIDPublisher) { $0[roomID] != nil }
|
||||
beaconInfoSubject.send(LiveLocationOwnInfoUpdate(roomID: roomID, eventID: eventID, isLive: true))
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user