mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 20:09:04 +00:00
refactor(healthchat): move the session hooks onto UserHooks
This commit is contained in:
@@ -14,28 +14,19 @@ import SwiftUI
|
||||
final class HealthChatSettingsScreenHook: SettingsScreenHookProtocol {
|
||||
// Owned here rather than by the section: the settings screen asks for the section on
|
||||
// every body pass. Nothing is fetched until the screen appears and asks for a refresh.
|
||||
private var statusLoader: HealthChatAccountStatusLoader?
|
||||
private let statusLoader: HealthChatAccountStatusLoader
|
||||
|
||||
// Constructed during hook registration, before the main actor is reachable.
|
||||
nonisolated init() { }
|
||||
|
||||
func configure(with userSession: UserSessionProtocol?) async {
|
||||
statusLoader = userSession.map {
|
||||
let apiService = HealthChatAPIService(tokenProvider: HealthChatOpenIDTokenProvider(clientProxy: $0.clientProxy))
|
||||
return HealthChatAccountStatusLoader(apiService: apiService)
|
||||
}
|
||||
init(statusLoader: HealthChatAccountStatusLoader) {
|
||||
self.statusLoader = statusLoader
|
||||
}
|
||||
|
||||
func accountStatusSection(completeProfileAction: @escaping () -> Void) -> AnyView? {
|
||||
guard let statusLoader else {
|
||||
return nil
|
||||
}
|
||||
return AnyView(HealthChatAccountStatusSection(loader: statusLoader,
|
||||
completeProfileAction: completeProfileAction))
|
||||
AnyView(HealthChatAccountStatusSection(loader: statusLoader,
|
||||
completeProfileAction: completeProfileAction))
|
||||
}
|
||||
|
||||
func refreshAccountStatus() {
|
||||
statusLoader?.load()
|
||||
statusLoader.load()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user