mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Guard user suggestions behind feature flag so that they don't impact releasability of other room creation features (#770)
This commit is contained in:
parent
0911f9ba89
commit
f368da3485
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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])
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
1
changelog.d/pr-770.change
Normal file
1
changelog.d/pr-770.change
Normal file
@ -0,0 +1 @@
|
||||
Guard user suggestions behind feature flag so that they don't impact releasability of other room creation features
|
Loading…
x
Reference in New Issue
Block a user