Guard user suggestions behind feature flag so that they don't impact releasability of other room creation features (#770)

This commit is contained in:
Johannes Marbach 2023-04-06 15:32:49 +02:00 committed by GitHub
parent 0911f9ba89
commit f368da3485
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 10 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -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
}

View File

@ -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")
}

View File

@ -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])
}

View File

@ -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 {

View File

@ -0,0 +1 @@
Guard user suggestions behind feature flag so that they don't impact releasability of other room creation features