Replace individual RoomProxy properties with a stored RoomInfo. (#3445)

* Store RoomInfo updates in JoinedRoomProxy and read from them directly.

* Remove all RoomProxy properties that were reading from the RoomInfo.
This commit is contained in:
Doug
2024-10-28 12:29:31 +00:00
committed by GitHub
parent 7c28d9709f
commit 7c75498b4d
29 changed files with 353 additions and 580 deletions
+14 -16
View File
@@ -349,10 +349,11 @@ class TimelineViewModelTests: XCTestCase {
// MARK: - Pins
func testPinnedEvents() async throws {
let roomProxyMock = JoinedRoomProxyMock(.init(name: "",
pinnedEventIDs: .init(["test1"])))
let actionsSubject = PassthroughSubject<JoinedRoomProxyAction, Never>()
roomProxyMock.underlyingActionsPublisher = actionsSubject.eraseToAnyPublisher()
var configuration = JoinedRoomProxyMockConfiguration(name: "",
pinnedEventIDs: .init(["test1"]))
let roomProxyMock = JoinedRoomProxyMock(configuration)
let infoSubject = CurrentValueSubject<RoomInfoProxy, Never>(.init(roomInfo: RoomInfo(configuration)))
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
let viewModel = TimelineViewModel(roomProxy: roomProxyMock,
timelineController: MockRoomTimelineController(),
@@ -364,24 +365,21 @@ class TimelineViewModelTests: XCTestCase {
appSettings: ServiceLocator.shared.settings,
analyticsService: ServiceLocator.shared.analytics,
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings))
XCTAssertEqual(configuration.pinnedEventIDs, viewModel.context.viewState.pinnedEventIDs)
var deferred = deferFulfillment(viewModel.context.$viewState) { value in
value.pinnedEventIDs == ["test1"]
}
try await deferred.fulfill()
roomProxyMock.underlyingPinnedEventIDs = ["test1", "test2"]
deferred = deferFulfillment(viewModel.context.$viewState) { value in
configuration.pinnedEventIDs = ["test1", "test2"]
let deferred = deferFulfillment(viewModel.context.$viewState) { value in
value.pinnedEventIDs == ["test1", "test2"]
}
actionsSubject.send(.roomInfoUpdate)
infoSubject.send(.init(roomInfo: RoomInfo(configuration)))
try await deferred.fulfill()
}
func testCanUserPinEvents() async throws {
let roomProxyMock = JoinedRoomProxyMock(.init(name: "", canUserPin: true))
let actionsSubject = PassthroughSubject<JoinedRoomProxyAction, Never>()
roomProxyMock.underlyingActionsPublisher = actionsSubject.eraseToAnyPublisher()
let configuration = JoinedRoomProxyMockConfiguration(name: "", canUserPin: true)
let roomProxyMock = JoinedRoomProxyMock(configuration)
let infoSubject = CurrentValueSubject<RoomInfoProxy, Never>(.init(roomInfo: RoomInfo(configuration)))
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
let viewModel = TimelineViewModel(roomProxy: roomProxyMock,
timelineController: MockRoomTimelineController(),
@@ -403,7 +401,7 @@ class TimelineViewModelTests: XCTestCase {
deferred = deferFulfillment(viewModel.context.$viewState) { value in
!value.canCurrentUserPin
}
actionsSubject.send(.roomInfoUpdate)
infoSubject.send(.init(roomInfo: RoomInfo(configuration)))
try await deferred.fulfill()
}