5bc81d5b3b
iOS SwiftUI app with Supabase auth/realtime, Node.js backend, Docker/Supabase self-hosted infrastructure, and APNs scheduler. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34 lines
827 B
Swift
34 lines
827 B
Swift
import Foundation
|
|
|
|
@MainActor
|
|
class ProfileViewModel: ObservableObject {
|
|
@Published var posts: [Post] = []
|
|
@Published var streak: Int = 0
|
|
@Published var isLoading = false
|
|
|
|
let userId: UUID
|
|
|
|
init(userId: UUID) {
|
|
self.userId = userId
|
|
}
|
|
|
|
convenience init(userIdString: String) {
|
|
self.init(userId: UUID(uuidString: userIdString) ?? UUID())
|
|
}
|
|
|
|
func load() async {
|
|
isLoading = true
|
|
defer { isLoading = false }
|
|
do {
|
|
async let postsTask = supabase.getUserPosts(userId: userId)
|
|
async let streakTask = supabase.getStreak(userId: userId)
|
|
(posts, streak) = try await (postsTask, streakTask)
|
|
} catch {
|
|
#if DEBUG
|
|
posts = Post.previews
|
|
streak = 4
|
|
#endif
|
|
}
|
|
}
|
|
}
|