Multi account feature flag (#6261)

* Add a multi-account feature flag

The flag lives in Developer options. Switching it on arms the upcoming one-time multi-account announcement, whose seen state defaults to true so fresh installs never see it.

* Add an Add account row to Settings behind the multi-account flag

The row sits in its own section under the user status, as in the designs. Tapping it is routed up to the settings flow, which ignores it until the add account flow exists.

* Remove the Developer options view model tests

The Developer options screen is excluded from coverage, so these tests don't add value.

* Apply review suggestions to the multi-account flag

- Order the multi-account requirements in DeveloperOptionsProtocol to match the screen's sections.
- Drop the redundant "Experimental" from the toggle's subtitle.
This commit is contained in:
Mauro
2026-10-05 13:04:16 +02:00
committed by GitHub
parent 9ce3bd97d8
commit 49457f7ae8
19 changed files with 113 additions and 21 deletions
@@ -23,6 +23,7 @@ enum SettingsScreenCoordinatorAction {
case secureBackup
case userDetails
case userStatusEmojiPicker(EmojiPickerScreenContinuation)
case addAccount
case analytics
case appLock
case bugReport
@@ -67,6 +68,8 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.userDetails)
case let .userStatusEmojiPicker(continuation):
actionsSubject.send(.userStatusEmojiPicker(continuation))
case .addAccount:
actionsSubject.send(.addAccount)
case .linkNewDevice:
actionsSubject.send(.linkNewDevice)
case let .manageAccount(url):
@@ -12,6 +12,7 @@ enum SettingsScreenViewModelAction {
case close
case userDetails
case userStatusEmojiPicker(EmojiPickerScreenContinuation)
case addAccount
case linkNewDevice
case manageAccount(url: URL)
case analytics
@@ -38,6 +39,7 @@ struct SettingsScreenViewState: BindableState {
var userProfile: UserProfile
var showUserStatusInput = false
var showLinkNewDeviceButton: Bool
var showAddAccountButton: Bool
var accountProfileURL: URL?
var showAccountDeactivation: Bool
var showDeveloperOptions: Bool
@@ -83,6 +85,7 @@ enum SettingsScreenViewAction {
case close
case userDetails
case userStatus(UserStatusAction)
case addAccount
case analytics
case appLock
case reportBug
@@ -30,6 +30,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
super.init(initialViewState: .init(deviceID: userSession.clientProxy.deviceID,
userProfile: userSession.clientProxy.userProfilePublisher.value,
showLinkNewDeviceButton: userSettings.linkNewDeviceEnabled,
showAddAccountButton: userSettings.multiAccountEnabled,
showAccountDeactivation: userSession.clientProxy.canDeactivateAccount,
showDeveloperOptions: userSettings.developerOptionsEnabled,
showAnalyticsSettings: userSettings.canPromptForAnalytics,
@@ -45,6 +46,10 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
.weakAssign(to: \.state.showLinkNewDeviceButton, on: self)
.store(in: &cancellables)
userSettings.multiAccountEnabledPublisher
.weakAssign(to: \.state.showAddAccountButton, on: self)
.store(in: &cancellables)
userSession.clientProxy.userProfilePublisher
.receive(on: DispatchQueue.main)
.weakAssign(to: \.state.userProfile, on: self)
@@ -113,6 +118,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
case .userStatus(.cancel):
state.bindings.isPresentingStatusPicker = false
state.bindings.isShowingCustomStatusField = false
case .addAccount:
actionsSubject.send(.addAccount)
case .linkNewDevice:
actionsSubject.send(.linkNewDevice)
case let .manageAccount(url):
@@ -27,6 +27,10 @@ struct SettingsScreen: View {
userStatusSection
}
if context.viewState.showAddAccountButton {
addAccountSection
}
if !shouldHideManageAccountSection {
manageAccountSection
}
@@ -98,6 +102,17 @@ struct SettingsScreen: View {
}
}
private var addAccountSection: some View {
Section {
ListRow(label: .default(title: L10n.screenSettingsAddAccount,
icon: \.plus),
kind: .navigationLink {
context.send(viewAction: .addAccount)
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.addAccount)
}
}
private var manageMyAppSection: some View {
Section {
ListRow(label: .default(title: L10n.screenNotificationSettingsTitle,
@@ -288,7 +303,7 @@ struct SettingsScreen_Previews: PreviewProvider, TestablePreview {
SettingsScreen(context: viewModel.context)
}
.snapshotPreferences(expect: viewModel.context.observe(\.viewState.accountProfileURL).map { $0 != nil })
.frame(height: 1100)
.frame(height: 1200)
.previewLayout(.sizeThatFits)
.previewDisplayName("Default")
@@ -296,7 +311,7 @@ struct SettingsScreen_Previews: PreviewProvider, TestablePreview {
SettingsScreen(context: bugReportDisabledViewModel.context)
}
.snapshotPreferences(expect: bugReportDisabledViewModel.context.observe(\.viewState.accountProfileURL).map { $0 != nil })
.frame(height: 1050)
.frame(height: 1150)
.previewLayout(.sizeThatFits)
.previewDisplayName("Bug report disabled")
}
@@ -306,8 +321,10 @@ struct SettingsScreen_Previews: PreviewProvider, TestablePreview {
deviceID: "AAAAAAAAAAA",
displayName: "Alice Liddell",
status: .mockFocussing))))
let userSettings = UserSettings.volatile()
userSettings.multiAccountEnabled = true
return SettingsScreenViewModel(userSession: userSession,
userSettings: .volatile(),
userSettings: userSettings,
isBugReportServiceEnabled: isBugReportServiceEnabled,
isInSecondaryWindow: false,
userIndicatorController: UserIndicatorControllerMock())