Files
denshooter 5bc81d5b3b Initial commit: nightly iOS app + Supabase backend
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>
2026-04-23 23:31:38 +02:00

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
}
}
}