Add room's update publisher (#952)

* Add room update publisher

* Cleanup

* Update room’s title

* Add refresh logic in RoomDetailsScreenViewModel

* Fix UTs

* Add UT

* Update timeline listener in RoomProxy

* Fix caching in LoadableAvatarImage

* Cleanup

* Update RoomProxy api

* Inject room proxy in RoomScreenViewModel

* Cleanup

* Fix UTs
This commit is contained in:
Alfonso Grillo
2023-05-25 12:42:58 +02:00
committed by GitHub
parent c59921103d
commit bf2102e5d1
15 changed files with 169 additions and 105 deletions
@@ -214,4 +214,9 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
await Task.yield()
XCTAssertTrue(callbackCorrectlyCalled)
}
func testRoomSubscription() async {
await context.nextViewState()
XCTAssertEqual(roomProxyMock.registerTimelineListenerIfNeededCallsCount, 1)
}
}
@@ -35,7 +35,7 @@ class RoomScreenViewModelTests: XCTestCase {
timelineController.timelineItems = items
let viewModel = RoomScreenViewModel(timelineController: timelineController,
mediaProvider: MockMediaProvider(),
roomName: nil)
roomProxy: RoomProxyMock(with: .init(displayName: "")))
// Then the messages should be grouped together.
XCTAssertEqual(viewModel.state.items[0].timelineGroupStyle, .first, "Nothing should prevent the first message from being grouped.")
@@ -65,7 +65,7 @@ class RoomScreenViewModelTests: XCTestCase {
timelineController.timelineItems = items
let viewModel = RoomScreenViewModel(timelineController: timelineController,
mediaProvider: MockMediaProvider(),
roomName: nil)
roomProxy: RoomProxyMock(with: .init(displayName: "")))
// Then the messages should be grouped by sender.
XCTAssertEqual(viewModel.state.items[0].timelineGroupStyle, .single, "A message should not be grouped when the sender changes.")
@@ -93,7 +93,7 @@ class RoomScreenViewModelTests: XCTestCase {
timelineController.timelineItems = items
let viewModel = RoomScreenViewModel(timelineController: timelineController,
mediaProvider: MockMediaProvider(),
roomName: nil)
roomProxy: RoomProxyMock(with: .init(displayName: "")))
// Then the first message should not be grouped but the other two should.
XCTAssertEqual(viewModel.state.items[0].timelineGroupStyle, .single, "When the first message has reactions it should not be grouped.")
@@ -118,7 +118,7 @@ class RoomScreenViewModelTests: XCTestCase {
timelineController.timelineItems = items
let viewModel = RoomScreenViewModel(timelineController: timelineController,
mediaProvider: MockMediaProvider(),
roomName: nil)
roomProxy: RoomProxyMock(with: .init(displayName: "")))
// Then the first and second messages should be grouped and the last one should not.
XCTAssertEqual(viewModel.state.items[0].timelineGroupStyle, .first, "Nothing should prevent the first message from being grouped.")
@@ -143,7 +143,7 @@ class RoomScreenViewModelTests: XCTestCase {
timelineController.timelineItems = items
let viewModel = RoomScreenViewModel(timelineController: timelineController,
mediaProvider: MockMediaProvider(),
roomName: nil)
roomProxy: RoomProxyMock(with: .init(displayName: "")))
// Then the messages should be grouped together.
XCTAssertEqual(viewModel.state.items[0].timelineGroupStyle, .first, "Nothing should prevent the first message from being grouped.")