diff --git a/ElementX/Sources/Application/AppSettings.swift b/ElementX/Sources/Application/AppSettings.swift index e224a8bba..bc97703ce 100644 --- a/ElementX/Sources/Application/AppSettings.swift +++ b/ElementX/Sources/Application/AppSettings.swift @@ -28,6 +28,7 @@ final class AppSettings: ObservableObject { case pusherProfileTag case shouldCollapseRoomStateEvents case startChatFlowEnabled = "showStartChatFlow" + case startChatUserSuggestionsEnabled case mediaUploadingFlowEnabled } @@ -164,6 +165,9 @@ final class AppSettings: ObservableObject { @UserSetting(key: UserDefaultsKeys.startChatFlowEnabled.rawValue, defaultValue: false, persistIn: store) var startChatFlowEnabled + @UserSetting(key: UserDefaultsKeys.startChatUserSuggestionsEnabled.rawValue, defaultValue: false, persistIn: nil) + var startChatUserSuggestionsEnabled + // MARK: Media Uploading @UserSetting(key: UserDefaultsKeys.mediaUploadingFlowEnabled.rawValue, defaultValue: false, persistIn: nil) diff --git a/ElementX/Sources/Screens/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift b/ElementX/Sources/Screens/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift index cca32e7e8..d23fdcb07 100644 --- a/ElementX/Sources/Screens/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift +++ b/ElementX/Sources/Screens/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift @@ -25,11 +25,13 @@ struct DeveloperOptionsScreenViewState: BindableState { struct DeveloperOptionsScreenViewStateBindings { var shouldCollapseRoomStateEvents: Bool var startChatFlowEnabled: Bool + var startChatUserSuggestionsEnabled: Bool var mediaUploadFlowEnabled: Bool } enum DeveloperOptionsScreenViewAction { case changedShouldCollapseRoomStateEvents case changedStartChatFlowEnabled + case changedStartChatUserSuggestionsEnabled case changedMediaUploadFlowEnabled } diff --git a/ElementX/Sources/Screens/DeveloperOptionsScreen/DeveloperOptionsScreenViewModel.swift b/ElementX/Sources/Screens/DeveloperOptionsScreen/DeveloperOptionsScreenViewModel.swift index 5cc56cad0..b57ced5a3 100644 --- a/ElementX/Sources/Screens/DeveloperOptionsScreen/DeveloperOptionsScreenViewModel.swift +++ b/ElementX/Sources/Screens/DeveloperOptionsScreen/DeveloperOptionsScreenViewModel.swift @@ -24,6 +24,7 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve init() { let bindings = DeveloperOptionsScreenViewStateBindings(shouldCollapseRoomStateEvents: ServiceLocator.shared.settings.shouldCollapseRoomStateEvents, startChatFlowEnabled: ServiceLocator.shared.settings.startChatFlowEnabled, + startChatUserSuggestionsEnabled: ServiceLocator.shared.settings.startChatUserSuggestionsEnabled, mediaUploadFlowEnabled: ServiceLocator.shared.settings.mediaUploadingFlowEnabled) let state = DeveloperOptionsScreenViewState(bindings: bindings) @@ -40,6 +41,8 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve ServiceLocator.shared.settings.shouldCollapseRoomStateEvents = state.bindings.shouldCollapseRoomStateEvents case .changedStartChatFlowEnabled: ServiceLocator.shared.settings.startChatFlowEnabled = state.bindings.startChatFlowEnabled + case .changedStartChatUserSuggestionsEnabled: + ServiceLocator.shared.settings.startChatUserSuggestionsEnabled = state.bindings.startChatUserSuggestionsEnabled case .changedMediaUploadFlowEnabled: ServiceLocator.shared.settings.mediaUploadingFlowEnabled = state.bindings.mediaUploadFlowEnabled } diff --git a/ElementX/Sources/Screens/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift b/ElementX/Sources/Screens/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift index 04f8bd1cb..1433201e3 100644 --- a/ElementX/Sources/Screens/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift +++ b/ElementX/Sources/Screens/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift @@ -37,6 +37,13 @@ struct DeveloperOptionsScreen: View { context.send(viewAction: .changedStartChatFlowEnabled) } + Toggle(isOn: $context.startChatUserSuggestionsEnabled) { + Text("Start chat user suggestions") + } + .onChange(of: context.startChatUserSuggestionsEnabled) { _ in + context.send(viewAction: .changedStartChatUserSuggestionsEnabled) + } + Toggle(isOn: $context.mediaUploadFlowEnabled) { Text("Show Media Uploading flow") } diff --git a/ElementX/Sources/Screens/StartChat/StartChatViewModel.swift b/ElementX/Sources/Screens/StartChat/StartChatViewModel.swift index 1210e1f05..b9345cf26 100644 --- a/ElementX/Sources/Screens/StartChat/StartChatViewModel.swift +++ b/ElementX/Sources/Screens/StartChat/StartChatViewModel.swift @@ -142,6 +142,10 @@ class StartChatViewModel: StartChatViewModelType, StartChatViewModelProtocol { } private func fetchSuggestions() { + guard ServiceLocator.shared.settings.startChatUserSuggestionsEnabled else { + state.usersSection = .init(type: .suggestions, users: []) + return + } state.usersSection = .init(type: .suggestions, users: [.mockAlice, .mockBob, .mockCharlie]) } diff --git a/ElementX/Sources/Screens/StartChat/View/StartChatScreen.swift b/ElementX/Sources/Screens/StartChat/View/StartChatScreen.swift index dc5b7c07e..581d016d3 100644 --- a/ElementX/Sources/Screens/StartChat/View/StartChatScreen.swift +++ b/ElementX/Sources/Screens/StartChat/View/StartChatScreen.swift @@ -81,20 +81,23 @@ struct StartChatScreen: View { .formSectionStyle() } + @ViewBuilder private var usersSection: some View { - Section { - ForEach(context.viewState.usersSection.users, id: \.userID) { user in - Button { context.send(viewAction: .selectUser(user)) } label: { - StartChatSuggestedUserCell(user: user, imageProvider: context.imageProvider) + if !context.viewState.usersSection.users.isEmpty { + Section { + ForEach(context.viewState.usersSection.users, id: \.userID) { user in + Button { context.send(viewAction: .selectUser(user)) } label: { + StartChatSuggestedUserCell(user: user, imageProvider: context.imageProvider) + } + } + } header: { + if let title = context.viewState.usersSection.type.title { + Text(title) } } - } header: { - if let title = context.viewState.usersSection.type.title { - Text(title) - } + .listRowSeparator(.automatic) + .formSectionStyle() } - .listRowSeparator(.automatic) - .formSectionStyle() } private var noResultsContent: some View { diff --git a/changelog.d/pr-770.change b/changelog.d/pr-770.change new file mode 100644 index 000000000..8dffad695 --- /dev/null +++ b/changelog.d/pr-770.change @@ -0,0 +1 @@ +Guard user suggestions behind feature flag so that they don't impact releasability of other room creation features \ No newline at end of file