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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import Foundation
import SwiftUI
extension AppModel {
func invalidateContent() {
withContentUpdates { clearContent() }
}
func clearContent() {
for pending in postLoadTasks.values { pending.task.cancel() }
postLoadTasks = [:]
for pending in profileLoadTasks.values { pending.task.cancel() }
profileLoadTasks = [:]
resetSearch(query: "", kind: .accounts)
resetSavedPosts()
moderationDecisions.removeAll(keepingCapacity: true)
moderationExpiryCandidates.removeAll(keepingCapacity: true)
scheduleModerationExpiry(nil)
contentInputsChanged()
refreshNotificationsTask?.cancel()
refreshNotificationsTask = nil
refreshNotificationsID = UUID()
feedRefreshTask?.cancel()
feedRefreshTask = nil
feedRefreshID = UUID()
isRefreshingFeed = false
notificationsReadThrough = nil
initialNotificationsTask?.cancel()
initialNotificationsTask = nil
initialNotificationsRequest = UUID()
hasLoadedNotifications = false
contentGeneration = UUID()
clearPadContent()
clearCachedContent()
cursor = nil
hasMorePosts = false
feedRequest = nil
moreFeedRequest = nil
postRequests = [:]
profileRequests = [:]
moreProfileRequests = [:]
notificationsRequest = nil
moreNotificationsRequest = nil
isLoading = false
isLoadingMore = false
isLoadingPost = false
loadingPostIDs = []
failedPostIDs = []
postErrors = [:]
feedErrorMessage = nil
retryFeedPage = false
loadingProfileIDs = []
loadingMoreProfileIDs = []
isLoadingNotifications = false
isLoadingMoreNotifications = false
resumeNotificationLoads()
resumeFeedLoads()
}
private func clearCachedContent() {
posts = []
timelinePostIDs = []
replyContexts = [:]
repostedBy = [:]
threadContexts = [:]
threadPositions = [:]
profiles = [:]
profileLoadedAt = [:]
avatars.clear()
inlineImages.clear()
preparedPostText.removeAll()
authorPosts = [:]
profileCursors = [:]
profileRepostedBy = [:]
profileErrors = [:]
failedProfileRefreshIDs = []
notifications = []
notificationPageStarts = []
notificationsCursor = nil
notificationRequestedCursors = []
notificationPendingPageStart = false
notificationsErrorMessage = nil
failedNotificationsPage = false
hasMoreNotifications = false
}
private func clearPadContent() {
for state in padStates.values {
state.request = nil
state.isLoading = false
state.isLoadingMore = false
state.hasMore = false
state.cursor = nil
state.posts = []
state.replyContexts = [:]
state.repostedBy = [:]
state.rows = []
state.errorMessage = nil
}
}
}