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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import Foundation
struct ThreadPosition: Equatable, Sendable {
let index: Int
let count: Int
init?(index: Int, count: Int) {
guard count > 1, index > 0, index <= count else { return nil }
self.index = index
self.count = count
}
}
struct ThreadResult {
let posts: [Post]
let mutedPostIDs: Set<String>
let positions: [String: ThreadPosition]
init(posts: [Post], mutedPostIDs: Set<String>, positions: [String: ThreadPosition] = [:]) {
self.posts = posts
self.mutedPostIDs = mutedPostIDs
self.positions = positions
}
}
struct CustomFeed: Identifiable, Codable, Equatable, Sendable {
let id: String
let name: String
let avatarURL: URL?
}
enum TimelineFeedID: Hashable {
case following
case custom(String)
init(_ feed: CustomFeed?) {
self = feed.map { .custom($0.id) } ?? .following
}
}
enum CustomFeedError: Error {
case unavailable
}
struct FeedPage: Equatable, Sendable {
let posts: [Post]
let cursor: String?
let replyContexts: [String: [Post]]
let repostedBy: [String: Post.Author]
let mutedPostIDs: Set<String>
init(
posts: [Post], cursor: String?, replyContexts: [String: [Post]] = [:], repostedBy: [String: Post.Author] = [:],
mutedPostIDs: Set<String> = []
) {
self.posts = posts
self.cursor = cursor
self.replyContexts = replyContexts
self.repostedBy = repostedBy
self.mutedPostIDs = mutedPostIDs
}
}