mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
1edfb8057f
The banner kept telling the user to complete a profile they had just completed, and nothing was fetched until the screen was actually shown.
42 lines
1.5 KiB
Swift
42 lines
1.5 KiB
Swift
//
|
|
// Copyright 2026 Novaloop AG
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
#if IS_MAIN_APP
|
|
// Conforming to the nonisolated hook protocol would infer nonisolated, but the
|
|
// service is main-actor state — the hook's requirements are all @MainActor anyway.
|
|
@MainActor
|
|
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?
|
|
|
|
// 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)
|
|
}
|
|
}
|
|
|
|
func accountStatusSection(completeProfileAction: @escaping () -> Void) -> AnyView? {
|
|
guard let statusLoader else {
|
|
return nil
|
|
}
|
|
return AnyView(HealthChatAccountStatusSection(loader: statusLoader,
|
|
completeProfileAction: completeProfileAction))
|
|
}
|
|
|
|
func refreshAccountStatus() {
|
|
statusLoader?.load()
|
|
}
|
|
}
|
|
#endif
|