From 53702a8324ddcdfc1d99586d766e2e3baabf87ff Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 17 Jan 2020 21:13:17 -0500 Subject: [PATCH] Add pinned status refreshing Closes #82 --- .../Profile/ProfileTableViewController.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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) {