// // 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 Foundation import Observation /// Loads a user's extended profile for display, hiding profiles without any HealthChat fields. @Observable final class HealthChatExtendedProfileLoader { private(set) var profile: ExtendedProfile? /// The load kicked off on creation — await this in tests before asserting. @ObservationIgnored private(set) var loadingTask: Task? init(userID: String, service: ExtendedProfileServiceProtocol) { loadingTask = Task { guard case let .success(profile) = await service.profile(for: userID), profile.hasContent else { return } self.profile = profile } } /// Creates a loader with a fixed result, for previews. init(profile: ExtendedProfile?) { self.profile = profile } }