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>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user