Let members edit their profile and invite others (#12)

* Add HealthChat API and extended profile services

Expose OpenID tokens and homeserver credentials from the client proxy, and
add fork-only services for the HealthChat member directory backend
(api.healthchat.ch) plus a service that reads MSC4133 extended profile
fields directly from the homeserver. Groundwork for the members tab and
the profile screens.

Claude-Session: https://claude.ai/code/session_013qdTbAWsZj2quQzEkagXaS

* Show extended profile details on the profile screens

Add a UserProfileScreenHook that lets the fork inject an extra Form
section below the header of the user profile and room member details
screens. The HealthChat implementation loads the MSC4133 extended
profile fields and renders them with tappable phone/email/website
links, hiding the section entirely for profiles without any fields.

Strings live in a new fork-only HealthChat.strings table (de/en/fr,
generated as HealthChatL10n via SwiftGen) since Untranslated.strings
pins the English bundle.

Claude-Session: https://claude.ai/code/session_013qdTbAWsZj2quQzEkagXaS

* Add a member directory tab

Add a HomeTabsHook that lets the fork append an extra tab to the home
tab bar, and a HealthChat members flow behind it: a directory of all
approved members from the HealthChat API with server-side search,
pending-approval and error states, chat shortcuts and pushed member
profiles. Chats and calls are handed back to the session flow via the
hook's actions publisher.

Claude-Session: https://claude.ai/code/session_013qdTbAWsZj2quQzEkagXaS

* Let members edit their profile and invite others

Add a native profile editor for the HealthChat extended profile fields
(13 fields plus avatar, saved as a partial diff through the HealthChat
API so displayname derivation and Zitadel sync stay server-side), an
invitation sheet (email plus personal note) and a profile-completeness
hint on the member directory.

A new UserDetailsEditScreenHook lets the fork substitute the profile
editor behind the settings user row — the stock display-name editor
would let users edit a value the next profile update derives away.

Claude-Session: https://claude.ai/code/session_013qdTbAWsZj2quQzEkagXaS
This commit is contained in:
2026-09-22 17:04:37 +02:00
parent 93149f1cbd
commit b475cc7e9a
47 changed files with 1595 additions and 17 deletions
@@ -9,10 +9,12 @@ import Combine
import SwiftState
import SwiftUI
/// The flow behind the HealthChat "Members" tab: the member directory with
/// pushed member profiles. Chats and calls are handed off to the session flow.
/// The flow behind the HealthChat "Members" tab: the member directory with pushed member
/// profiles, the own-profile editor and the invitation sheet. Chats and calls are handed
/// off to the session flow.
final class HealthChatMembersFlowCoordinator {
private let flowParameters: CommonFlowParameters
private let apiService: HealthChatAPIServiceProtocol
let navigationStackCoordinator: NavigationStackCoordinator
@@ -25,6 +27,10 @@ final class HealthChatMembersFlowCoordinator {
case memberDirectory
/// A member's profile pushed on top of the directory.
case memberProfile
/// The own-profile editor pushed on top of the directory.
case profileEditor
/// The invitation sheet presented over the directory.
case inviteSheet
}
enum Event: EventType {
@@ -34,6 +40,14 @@ final class HealthChatMembersFlowCoordinator {
case showMemberProfile
/// The member profile has been dismissed.
case dismissedMemberProfile
/// Request presentation of the own-profile editor.
case showProfileEditor
/// The profile editor has been dismissed.
case dismissedProfileEditor
/// Request presentation of the invitation sheet.
case showInviteSheet
/// The invitation sheet has been dismissed.
case dismissedInviteSheet
}
private let stateMachine: StateMachine<State, Event>
@@ -45,6 +59,7 @@ final class HealthChatMembersFlowCoordinator {
init(flowParameters: CommonFlowParameters) {
self.flowParameters = flowParameters
apiService = HealthChatAPIService(tokenProvider: HealthChatOpenIDTokenProvider(clientProxy: flowParameters.userSession.clientProxy))
navigationStackCoordinator = NavigationStackCoordinator()
stateMachine = StateMachine(state: .initial)
@@ -64,9 +79,14 @@ final class HealthChatMembersFlowCoordinator {
}
stateMachine.addRoutes(event: .showMemberProfile, transitions: [.memberDirectory => .memberProfile])
stateMachine.addRoutes(event: .dismissedMemberProfile, transitions: [.memberProfile => .memberDirectory])
stateMachine.addRoutes(event: .showProfileEditor, transitions: [.memberDirectory => .profileEditor])
stateMachine.addRoutes(event: .dismissedProfileEditor, transitions: [.profileEditor => .memberDirectory])
stateMachine.addRoutes(event: .showInviteSheet, transitions: [.memberDirectory => .inviteSheet])
stateMachine.addRoutes(event: .dismissedInviteSheet, transitions: [.inviteSheet => .memberDirectory])
stateMachine.addErrorHandler { context in
fatalError("Unexpected transition from `\(context.fromState)` to `\(context.toState)` for event `\(String(describing: context.event))`.")
}
@@ -74,7 +94,6 @@ final class HealthChatMembersFlowCoordinator {
private func presentMemberDirectory() {
let userSession = flowParameters.userSession
let apiService = HealthChatAPIService(tokenProvider: HealthChatOpenIDTokenProvider(clientProxy: userSession.clientProxy))
let coordinator = HealthChatMemberDirectoryScreenCoordinator(parameters: .init(apiService: apiService,
clientProxy: userSession.clientProxy,
mediaProvider: userSession.mediaProvider,
@@ -87,6 +106,10 @@ final class HealthChatMembersFlowCoordinator {
presentMemberProfile(userID: userID)
case .presentRoom(let roomID):
actionsSubject.send(.presentRoom(roomID: roomID))
case .editProfile:
presentProfileEditor()
case .invite:
presentInviteSheet()
}
}
.store(in: &cancellables)
@@ -122,4 +145,48 @@ final class HealthChatMembersFlowCoordinator {
self?.stateMachine.tryEvent(.dismissedMemberProfile)
}
}
private func presentProfileEditor() {
let parameters = UserDetailsEditScreenCoordinatorParameters(orientationManager: flowParameters.windowManager,
userSession: flowParameters.userSession,
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: flowParameters.appSettings),
navigationStackCoordinator: navigationStackCoordinator,
userIndicatorController: flowParameters.userIndicatorController,
appSettings: flowParameters.appSettings)
let coordinator = flowParameters.appHooks.userDetailsEditScreenHook.makeCoordinator(parameters: parameters)
coordinator.actions.sink { [weak self] action in
switch action {
case .dismiss:
self?.navigationStackCoordinator.pop()
}
}
.store(in: &cancellables)
stateMachine.tryEvent(.showProfileEditor)
navigationStackCoordinator.push(coordinator) { [weak self] in
self?.stateMachine.tryEvent(.dismissedProfileEditor)
}
}
private func presentInviteSheet() {
let stackCoordinator = NavigationStackCoordinator()
let coordinator = HealthChatInviteMemberScreenCoordinator(parameters: .init(apiService: apiService,
userIndicatorController: flowParameters.userIndicatorController))
coordinator.actionsPublisher.sink { [weak self] action in
switch action {
case .dismiss:
self?.navigationStackCoordinator.setSheetCoordinator(nil)
}
}
.store(in: &cancellables)
stackCoordinator.setRootCoordinator(coordinator)
stateMachine.tryEvent(.showInviteSheet)
navigationStackCoordinator.setSheetCoordinator(stackCoordinator) { [weak self] in
self?.stateMachine.tryEvent(.dismissedInviteSheet)
}
}
}
@@ -179,11 +179,12 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
}
private func presentUserDetailsEditScreen() {
let coordinator = UserDetailsEditScreenCoordinator(parameters: .init(orientationManager: flowParameters.windowManager,
userSession: flowParameters.userSession,
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: flowParameters.appSettings),
navigationStackCoordinator: navigationStackCoordinator,
userIndicatorController: flowParameters.userIndicatorController))
let coordinator = flowParameters.appHooks.userDetailsEditScreenHook
.makeCoordinator(parameters: .init(orientationManager: flowParameters.windowManager,
userSession: flowParameters.userSession,
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: flowParameters.appSettings),
navigationStackCoordinator: navigationStackCoordinator,
userIndicatorController: flowParameters.userIndicatorController))
coordinator.actions
.sink { [weak self] action in
switch action {