~ knotless Search/
↑↓ move↵ open⇧↵ all results

geesawra.industries/old-fella

Old people's social media app

0
1
main
30 lines · 1000 B Raw History
import Observation

@MainActor
@Observable
final class PostViewState: Identifiable {
    let id: String
    private(set) var post: Post
    private(set) var isBusy = false
    private(set) var isUncertain = false
    private(set) var decision: ModerationPolicy.Decision?
    private(set) var quotedPost: Post?
    private(set) var replyContext: [Post] = []

    init(post: Post) {
        id = post.id
        self.post = post
    }

    func update(post: Post, isBusy: Bool, isUncertain: Bool, decision: ModerationPolicy.Decision?, quotedPost: Post?) {
        if self.post != post { self.post = post }
        if self.isBusy != isBusy { self.isBusy = isBusy }
        if self.isUncertain != isUncertain { self.isUncertain = isUncertain }
        if self.decision != decision { self.decision = decision }
        if self.quotedPost != quotedPost { self.quotedPost = quotedPost }
    }

    func updateReplyContext(_ posts: [Post]) {
        if replyContext != posts { replyContext = posts }
    }
}