1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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 }
}
}