Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Apr 6, 2023
4 changes: 4 additions & 0 deletions ElementX/Sources/Application/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ final class AppSettings: ObservableObject {
case pusherProfileTag
case shouldCollapseRoomStateEvents
case startChatFlowEnabled = "showStartChatFlow"
case startChatUserSuggestionsEnabled
case mediaUploadingFlowEnabled
}

Expand Down Expand Up @@ -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: store)
Johennes marked this conversation as resolved.
Show resolved Hide resolved
var startChatUserSuggestionsEnabled

// MARK: Media Uploading

@UserSetting(key: UserDefaultsKeys.mediaUploadingFlowEnabled.rawValue, defaultValue: false, persistIn: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class StartChatViewModel: StartChatViewModelType, StartChatViewModelProtocol {
}

private func fetchSuggestions() {
state.usersSection = .init(type: .suggestions, users: [.mockAlice, .mockBob, .mockCharlie])
state.usersSection = .init(type: .suggestions, users: ServiceLocator.shared.settings.startChatUserSuggestionsEnabled ? [.mockAlice, .mockBob, .mockCharlie] : [])
alfogrillo marked this conversation as resolved.
Show resolved Hide resolved
}

private func createDirectRoom(with user: UserProfile) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct StartChatScreen: View {
}
}
} header: {
if let title = context.viewState.usersSection.type.title {
if !context.viewState.usersSection.users.isEmpty, let title = context.viewState.usersSection.type.title {
Johennes marked this conversation as resolved.
Show resolved Hide resolved
Text(title)
}
}
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-770.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Guard user suggestions behind feature flag so that they don't impact releasability of other room creation features