mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Refactor SpaceServiceProxy.joinedSpaces to topLevelSpaces.
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user