Add pinned status refreshing

Closes #82
This commit is contained in:
Shadowfacts 2020-01-17 21:13:17 -05:00
parent bb86e1aafd
commit 53702a8324
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 18 additions and 0 deletions

View File

@ -226,6 +226,24 @@ class ProfileTableViewController: EnhancedTableViewController {
self.refreshControl?.endRefreshing()
}
}
getStatuses(onlyPinned: true) { (response) in
guard case let .success(newPinnedStatuses, _) = response else { fatalError() }
MastodonCache.addAll(statuses: newPinnedStatuses)
let oldPinnedStatuses = self.pinnedStatuses
var pinnedStatuses = [(id: String, state: StatusState)]()
for status in newPinnedStatuses {
let state: StatusState
if let (_, oldState) = oldPinnedStatuses.first(where: { $0.id == status.id }) {
state = oldState
} else {
state = .unknown
}
pinnedStatuses.append((status.id, state))
}
self.pinnedStatuses = pinnedStatuses
}
}
@objc func composePressed(_ sender: Any) {