diff --git a/Tusker/Screens/Profile/ProfileTableViewController.swift b/Tusker/Screens/Profile/ProfileTableViewController.swift index f969d7817a..2dc0100b72 100644 --- a/Tusker/Screens/Profile/ProfileTableViewController.swift +++ b/Tusker/Screens/Profile/ProfileTableViewController.swift @@ -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) {