mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
remove space FFs
This commit is contained in:
@@ -36,7 +36,6 @@ struct SpaceScreenViewState: BindableState {
|
||||
var canEditRolesAndPermissions = false
|
||||
var canEditSecurityAndPrivacy = false
|
||||
var canEditChildren = false
|
||||
var canCreateRoom = false
|
||||
|
||||
var editMode: EditMode = .inactive
|
||||
var editModeSelectedIDs: Set<String> = []
|
||||
|
||||
@@ -75,10 +75,6 @@ class SpaceScreenViewModel: SpaceScreenViewModelType, SpaceScreenViewModelProtoc
|
||||
.weakAssign(to: \.state.selectedSpaceRoomID, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.$createSpaceEnabled
|
||||
.weakAssign(to: \.state.canCreateRoom, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
Task {
|
||||
if case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(spaceRoomListProxy.id) {
|
||||
// Required to listen for membership updates in the members flow
|
||||
@@ -88,11 +84,10 @@ class SpaceScreenViewModel: SpaceScreenViewModelType, SpaceScreenViewModelProtoc
|
||||
state.permalink = permalinkURL
|
||||
}
|
||||
|
||||
appSettings.$spaceSettingsEnabled
|
||||
.combineLatest(roomProxy.infoPublisher)
|
||||
.sink { [weak self] isEnabled, roomInfo in
|
||||
roomProxy.infoPublisher
|
||||
.sink { [weak self] roomInfo in
|
||||
guard let self else { return }
|
||||
guard isEnabled, let powerLevels = roomInfo.powerLevels else {
|
||||
guard let powerLevels = roomInfo.powerLevels else {
|
||||
state.canEditBaseInfo = false
|
||||
state.canEditRolesAndPermissions = false
|
||||
state.canEditSecurityAndPrivacy = false
|
||||
@@ -247,7 +242,7 @@ class SpaceScreenViewModel: SpaceScreenViewModelType, SpaceScreenViewModelProtoc
|
||||
}
|
||||
|
||||
let leaveSpaceViewModel = LeaveSpaceViewModel(spaceName: state.space.name,
|
||||
canEditRolesAndPermissions: appSettings.spaceSettingsEnabled && state.canEditRolesAndPermissions,
|
||||
canEditRolesAndPermissions: state.canEditRolesAndPermissions,
|
||||
leaveHandle: leaveHandle,
|
||||
userIndicatorController: userIndicatorController,
|
||||
mediaProvider: mediaProvider)
|
||||
|
||||
@@ -78,12 +78,10 @@ struct SpaceScreen: View {
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
|
||||
if context.viewState.canCreateRoom {
|
||||
Button(L10n.actionCreateRoom) {
|
||||
context.send(viewAction: .createChildRoom)
|
||||
}
|
||||
.buttonStyle(.compound(.secondary))
|
||||
Button(L10n.actionCreateRoom) {
|
||||
context.send(viewAction: .createChildRoom)
|
||||
}
|
||||
.buttonStyle(.compound(.secondary))
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
@@ -128,11 +126,9 @@ struct SpaceScreen: View {
|
||||
Menu {
|
||||
if context.viewState.canEditChildren {
|
||||
Section {
|
||||
if context.viewState.canCreateRoom {
|
||||
Button { context.send(viewAction: .createChildRoom) } label: {
|
||||
Label(L10n.actionCreateRoom, icon: \.plus)
|
||||
}
|
||||
.accessibilityIdentifier(A11yIdentifiers.spaceScreen.createRoom)
|
||||
Button { context.send(viewAction: .createChildRoom) } label: {
|
||||
Label(L10n.actionCreateRoom, icon: \.plus)
|
||||
.accessibilityIdentifier(A11yIdentifiers.spaceScreen.createRoom)
|
||||
}
|
||||
|
||||
Button { context.send(viewAction: .addExistingRooms) } label: {
|
||||
@@ -207,16 +203,10 @@ struct SpaceScreen_Previews: PreviewProvider, TestablePreview {
|
||||
SpaceScreen(context: newSpaceViewModel.context)
|
||||
}
|
||||
.previewDisplayName("New Space")
|
||||
.snapshotPreferences(expect: newSpaceViewModel.context.observe(\.viewState).map {
|
||||
$0.canCreateRoom && $0.canEditChildren
|
||||
})
|
||||
.snapshotPreferences(expect: newSpaceViewModel.context.observe(\.viewState).map(\.canEditChildren))
|
||||
}
|
||||
|
||||
static func makeViewModel(isManagingRooms: Bool = false, isNewSpace: Bool = false) -> SpaceScreenViewModel {
|
||||
let appSettings = AppSettings()
|
||||
appSettings.spaceSettingsEnabled = true
|
||||
appSettings.createSpaceEnabled = true
|
||||
|
||||
let spaceServiceRoom = SpaceServiceRoom.mock(id: "!eng-space:matrix.org",
|
||||
name: "Engineering Team",
|
||||
isSpace: true,
|
||||
@@ -239,7 +229,7 @@ struct SpaceScreen_Previews: PreviewProvider, TestablePreview {
|
||||
spaceServiceProxy: SpaceServiceProxyMock(.init()),
|
||||
selectedSpaceRoomPublisher: .init(nil),
|
||||
userSession: userSession,
|
||||
appSettings: appSettings,
|
||||
appSettings: AppSettings(),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
|
||||
if isManagingRooms {
|
||||
|
||||
@@ -21,9 +21,7 @@ struct SpacesScreenViewState: BindableState {
|
||||
|
||||
var topLevelSpaces: [SpaceServiceRoom]
|
||||
var selectedSpaceID: String?
|
||||
|
||||
var isCreateSpaceEnabled: Bool
|
||||
|
||||
|
||||
var bindings: SpacesScreenViewStateBindings
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ class SpacesScreenViewModel: SpacesScreenViewModelType, SpacesScreenViewModelPro
|
||||
|
||||
super.init(initialViewState: SpacesScreenViewState(userID: userSession.clientProxy.userID,
|
||||
topLevelSpaces: spaceServiceProxy.topLevelSpacesPublisher.value,
|
||||
isCreateSpaceEnabled: appSettings.createSpaceEnabled,
|
||||
bindings: .init()),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
@@ -53,10 +52,6 @@ class SpacesScreenViewModel: SpacesScreenViewModelType, SpacesScreenViewModelPro
|
||||
.receive(on: DispatchQueue.main)
|
||||
.weakAssign(to: \.state.userDisplayName, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.$createSpaceEnabled
|
||||
.weakAssign(to: \.state.isCreateSpaceEnabled, on: self)
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
@@ -27,7 +27,7 @@ struct SpacesScreen: View {
|
||||
|
||||
@ViewBuilder
|
||||
private var mainContent: some View {
|
||||
if context.viewState.isCreateSpaceEnabled, context.viewState.topLevelSpaces.isEmpty {
|
||||
if context.viewState.topLevelSpaces.isEmpty {
|
||||
emptyState
|
||||
} else {
|
||||
ScrollView {
|
||||
@@ -118,16 +118,14 @@ struct SpacesScreen: View {
|
||||
}
|
||||
.backportSharedBackgroundVisibility(.hidden)
|
||||
|
||||
if context.viewState.isCreateSpaceEnabled {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
context.send(viewAction: .createSpace)
|
||||
} label: {
|
||||
CompoundIcon(\.plus)
|
||||
.accessibilityHidden(true)
|
||||
}
|
||||
.accessibilityLabel(L10n.actionCreateSpace)
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
context.send(viewAction: .createSpace)
|
||||
} label: {
|
||||
CompoundIcon(\.plus)
|
||||
.accessibilityHidden(true)
|
||||
}
|
||||
.accessibilityLabel(L10n.actionCreateSpace)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,7 +150,6 @@ struct SpacesScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static func makeViewModel(isEmpty: Bool = false) -> SpacesScreenViewModel {
|
||||
AppSettings.resetAllSettings()
|
||||
let appSettings = AppSettings()
|
||||
appSettings.createSpaceEnabled = true
|
||||
appSettings.hasSeenSpacesAnnouncement = true
|
||||
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
|
||||
Reference in New Issue
Block a user