Refactor SpaceServiceProxy.joinedSpaces to topLevelSpaces.

This commit is contained in:
Doug
2026-01-05 15:35:11 +00:00
committed by Doug
parent 3cbeca82bd
commit 44f88adfb0
12 changed files with 39 additions and 39 deletions
@@ -18,7 +18,7 @@ struct SpaceListScreenViewState: BindableState {
var userDisplayName: String?
var userAvatarURL: URL?
var joinedSpaces: [SpaceRoomProxyProtocol]
var topLevelSpaces: [SpaceRoomProxyProtocol]
var selectedSpaceID: String?
var bindings: SpaceListScreenViewStateBindings
@@ -30,13 +30,13 @@ class SpaceListScreenViewModel: SpaceListScreenViewModelType, SpaceListScreenVie
self.userIndicatorController = userIndicatorController
super.init(initialViewState: SpaceListScreenViewState(userID: userSession.clientProxy.userID,
joinedSpaces: spaceServiceProxy.joinedSpacesPublisher.value,
topLevelSpaces: spaceServiceProxy.topLevelSpacesPublisher.value,
bindings: .init()),
mediaProvider: userSession.mediaProvider)
spaceServiceProxy.joinedSpacesPublisher
spaceServiceProxy.topLevelSpacesPublisher
.receive(on: DispatchQueue.main)
.weakAssign(to: \.state.joinedSpaces, on: self)
.weakAssign(to: \.state.topLevelSpaces, on: self)
.store(in: &cancellables)
selectedSpacePublisher
@@ -40,7 +40,7 @@ struct SpaceListScreen: View {
.foregroundStyle(.compound.textPrimary)
.multilineTextAlignment(.center)
Text(L10n.commonSpaces(context.viewState.joinedSpaces.count))
Text(L10n.commonSpaces(context.viewState.topLevelSpaces.count))
.font(.compound.bodyLG)
.foregroundStyle(.compound.textSecondary)
.multilineTextAlignment(.center)
@@ -63,7 +63,7 @@ struct SpaceListScreen: View {
}
var spaces: some View {
ForEach(context.viewState.joinedSpaces, id: \.id) { spaceRoomProxy in
ForEach(context.viewState.topLevelSpaces, id: \.id) { spaceRoomProxy in
SpaceRoomCell(spaceRoomProxy: spaceRoomProxy,
isSelected: spaceRoomProxy.id == context.viewState.selectedSpaceID,
mediaProvider: context.mediaProvider) { action in
@@ -111,7 +111,7 @@ struct SpaceListScreen_Previews: PreviewProvider, TestablePreview {
static func makeViewModel() -> SpaceListScreenViewModel {
let clientProxy = ClientProxyMock(.init())
clientProxy.spaceService = SpaceServiceProxyMock(.init(joinedSpaces: .mockJoinedSpaces))
clientProxy.spaceService = SpaceServiceProxyMock(.init(topLevelSpaces: .mockJoinedSpaces))
let viewModel = SpaceListScreenViewModel(userSession: UserSessionMock(.init(clientProxy: clientProxy)),
selectedSpacePublisher: .init(nil),