diff --git a/Pachyderm/Sources/Pachyderm/Utilities/StatusState.swift b/Pachyderm/Sources/Pachyderm/Utilities/CollapseState.swift similarity index 64% rename from Pachyderm/Sources/Pachyderm/Utilities/StatusState.swift rename to Pachyderm/Sources/Pachyderm/Utilities/CollapseState.swift index 3bb71e9b..6370d7e9 100644 --- a/Pachyderm/Sources/Pachyderm/Utilities/StatusState.swift +++ b/Pachyderm/Sources/Pachyderm/Utilities/CollapseState.swift @@ -1,5 +1,5 @@ // -// StatusState.swift +// CollapseState.swift // Pachyderm // // Created by Shadowfacts on 11/24/19. @@ -8,7 +8,7 @@ import Foundation -public class StatusState: Equatable { +public class CollapseState: Equatable { public var collapsible: Bool? public var collapsed: Bool? @@ -21,8 +21,8 @@ public class StatusState: Equatable { self.collapsed = collapsed } - public func copy() -> StatusState { - return StatusState(collapsible: self.collapsible, collapsed: self.collapsed) + public func copy() -> CollapseState { + return CollapseState(collapsible: self.collapsible, collapsed: self.collapsed) } public func hash(into hasher: inout Hasher) { @@ -30,11 +30,11 @@ public class StatusState: Equatable { hasher.combine(collapsed) } - public static var unknown: StatusState { - StatusState(collapsible: nil, collapsed: nil) + public static var unknown: CollapseState { + CollapseState(collapsible: nil, collapsed: nil) } - public static func == (lhs: StatusState, rhs: StatusState) -> Bool { + public static func == (lhs: CollapseState, rhs: CollapseState) -> Bool { lhs.collapsible == rhs.collapsible && lhs.collapsed == rhs.collapsed } } diff --git a/Pachyderm/Sources/Pachyderm/Utilities/NotificationGroup.swift b/Pachyderm/Sources/Pachyderm/Utilities/NotificationGroup.swift index cab861b0..655a930a 100644 --- a/Pachyderm/Sources/Pachyderm/Utilities/NotificationGroup.swift +++ b/Pachyderm/Sources/Pachyderm/Utilities/NotificationGroup.swift @@ -12,7 +12,7 @@ public struct NotificationGroup: Identifiable, Hashable { public private(set) var notifications: [Notification] public let id: String public let kind: Notification.Kind - public let statusState: StatusState? + public let statusState: CollapseState? init?(notifications: [Notification]) { guard !notifications.isEmpty else { return nil } diff --git a/Tusker/Extensions/StatusStateResolver.swift b/Tusker/Extensions/StatusStateResolver.swift index 34f8bd8a..266c2afa 100644 --- a/Tusker/Extensions/StatusStateResolver.swift +++ b/Tusker/Extensions/StatusStateResolver.swift @@ -9,7 +9,7 @@ import Foundation import Pachyderm -extension StatusState { +extension CollapseState { func resolveFor(status: StatusMO, height: CGFloat, textLength: Int? = nil) { let longEnoughToCollapse: Bool diff --git a/Tusker/Screens/Bookmarks/BookmarksTableViewController.swift b/Tusker/Screens/Bookmarks/BookmarksTableViewController.swift index 0479e1df..b4e48521 100644 --- a/Tusker/Screens/Bookmarks/BookmarksTableViewController.swift +++ b/Tusker/Screens/Bookmarks/BookmarksTableViewController.swift @@ -17,7 +17,7 @@ class BookmarksTableViewController: EnhancedTableViewController { private var loaded = false - var statuses: [(id: String, state: StatusState)] = [] + var statuses: [(id: String, state: CollapseState)] = [] var newer: RequestRange? var older: RequestRange? diff --git a/Tusker/Screens/Conversation/ConversationTableViewController.swift b/Tusker/Screens/Conversation/ConversationTableViewController.swift index 2884e698..608219d3 100644 --- a/Tusker/Screens/Conversation/ConversationTableViewController.swift +++ b/Tusker/Screens/Conversation/ConversationTableViewController.swift @@ -30,7 +30,7 @@ class ConversationTableViewController: EnhancedTableViewController { weak var mastodonController: MastodonController! let mainStatusID: String - let mainStatusState: StatusState + let mainStatusState: CollapseState var statusIDToScrollToOnLoad: String private(set) var dataSource: UITableViewDiffableDataSource! @@ -39,7 +39,7 @@ class ConversationTableViewController: EnhancedTableViewController { private var loadingState = LoadingState.unloaded - init(for mainStatusID: String, state: StatusState = .unknown, mastodonController: MastodonController) { + init(for mainStatusID: String, state: CollapseState = .unknown, mastodonController: MastodonController) { self.mainStatusID = mainStatusID self.mainStatusState = state self.statusIDToScrollToOnLoad = mainStatusID @@ -336,7 +336,7 @@ class ConversationTableViewController: EnhancedTableViewController { } } - func item(for indexPath: IndexPath) -> (id: String, state: StatusState)? { + func item(for indexPath: IndexPath) -> (id: String, state: CollapseState)? { return self.dataSource.itemIdentifier(for: indexPath).flatMap { (item) in switch item { case let .status(id: id, state: state): @@ -402,7 +402,7 @@ extension ConversationTableViewController { case childThread(firstStatusID: String) } enum Item: Hashable { - case status(id: String, state: StatusState) + case status(id: String, state: CollapseState) case expandThread(childThreads: [ConversationNode], inline: Bool) static func == (lhs: Item, rhs: Item) -> Bool { @@ -443,7 +443,7 @@ extension ConversationTableViewController { extension ConversationTableViewController: TuskerNavigationDelegate { var apiController: MastodonController! { mastodonController } - func conversation(mainStatusID: String, state: StatusState) -> ConversationTableViewController { + func conversation(mainStatusID: String, state: CollapseState) -> ConversationTableViewController { let vc = ConversationTableViewController(for: mainStatusID, state: state, mastodonController: mastodonController) // transfer show statuses automatically state when showing new conversation vc.showStatusesAutomatically = self.showStatusesAutomatically diff --git a/Tusker/Screens/Explore/TrendingStatusesViewController.swift b/Tusker/Screens/Explore/TrendingStatusesViewController.swift index 56f10fb3..66e1e044 100644 --- a/Tusker/Screens/Explore/TrendingStatusesViewController.swift +++ b/Tusker/Screens/Explore/TrendingStatusesViewController.swift @@ -62,7 +62,7 @@ class TrendingStatusesViewController: UIViewController { } private func createDataSource() -> UICollectionViewDiffableDataSource { - let statusCell = UICollectionView.CellRegistration { [unowned self] cell, indexPath, item in + let statusCell = UICollectionView.CellRegistration { [unowned self] cell, indexPath, item in cell.delegate = self cell.updateUI(statusID: item.0, state: item.1) } @@ -119,7 +119,7 @@ extension TrendingStatusesViewController { case statuses } enum Item: Hashable { - case status(id: String, state: StatusState) + case status(id: String, state: CollapseState) case loadingIndicator static func ==(lhs: Item, rhs: Item) -> Bool { diff --git a/Tusker/Screens/Profile/ProfileStatusesViewController.swift b/Tusker/Screens/Profile/ProfileStatusesViewController.swift index 1b7df2c5..bcbd39da 100644 --- a/Tusker/Screens/Profile/ProfileStatusesViewController.swift +++ b/Tusker/Screens/Profile/ProfileStatusesViewController.swift @@ -110,7 +110,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie private func createDataSource() -> UICollectionViewDiffableDataSource { collectionView.register(ProfileHeaderCollectionViewCell.self, forCellWithReuseIdentifier: "headerCell") - let statusCell = UICollectionView.CellRegistration { [unowned self] cell, indexPath, item in + let statusCell = UICollectionView.CellRegistration { [unowned self] cell, indexPath, item in cell.delegate = self cell.showPinned = item.2 cell.updateUI(statusID: item.0, state: item.1) @@ -288,7 +288,7 @@ extension ProfileStatusesViewController { typealias TimelineItem = String case header(String) - case status(id: String, state: StatusState, pinned: Bool) + case status(id: String, state: CollapseState, pinned: Bool) case loadingIndicator case confirmLoadMore diff --git a/Tusker/Screens/Search/SearchResultsViewController.swift b/Tusker/Screens/Search/SearchResultsViewController.swift index b42f6016..b4ce3b72 100644 --- a/Tusker/Screens/Search/SearchResultsViewController.swift +++ b/Tusker/Screens/Search/SearchResultsViewController.swift @@ -248,7 +248,7 @@ extension SearchResultsViewController { enum Item: Hashable { case account(String) case hashtag(Hashtag) - case status(String, StatusState) + case status(String, CollapseState) func hash(into hasher: inout Hasher) { switch self { diff --git a/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift b/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift index b6a098da..2cb57831 100644 --- a/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift +++ b/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift @@ -14,7 +14,7 @@ class StatusActionAccountListViewController: UIViewController { private let mastodonController: MastodonController private let actionType: ActionType private let statusID: String - private let statusState: StatusState + private let statusState: CollapseState private var accountIDs: [String]? /// If `true`, a warning will be shown below the account list describing that the total favs/reblogs may be innacurate. @@ -33,7 +33,7 @@ class StatusActionAccountListViewController: UIViewController { - Parameter accountIDs The accounts that will be shown. If `nil` is passed, a request will be performed to load the accounts. - Parameter mastodonController The `MastodonController` instance this view controller uses. */ - init(actionType: ActionType, statusID: String, statusState: StatusState, accountIDs: [String]?, mastodonController: MastodonController) { + init(actionType: ActionType, statusID: String, statusState: CollapseState, accountIDs: [String]?, mastodonController: MastodonController) { self.mastodonController = mastodonController self.actionType = actionType self.statusID = statusID diff --git a/Tusker/Screens/Timeline/InstanceTimelineViewController.swift b/Tusker/Screens/Timeline/InstanceTimelineViewController.swift index 929ebc5a..d7d25906 100644 --- a/Tusker/Screens/Timeline/InstanceTimelineViewController.swift +++ b/Tusker/Screens/Timeline/InstanceTimelineViewController.swift @@ -69,7 +69,7 @@ class InstanceTimelineViewController: TimelineViewController { toggleSaveButton.title = toggleSaveButtonTitle } - override func configureStatusCell(_ cell: TimelineStatusCollectionViewCell, id: String, state: StatusState) { + override func configureStatusCell(_ cell: TimelineStatusCollectionViewCell, id: String, state: CollapseState) { cell.delegate = browsingEnabled ? self : nil cell.overrideMastodonController = mastodonController cell.updateUI(statusID: id, state: state) diff --git a/Tusker/Screens/Timeline/TimelineViewController.swift b/Tusker/Screens/Timeline/TimelineViewController.swift index a9a86dcf..8a2a2521 100644 --- a/Tusker/Screens/Timeline/TimelineViewController.swift +++ b/Tusker/Screens/Timeline/TimelineViewController.swift @@ -99,7 +99,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro } // separate method because InstanceTimelineViewController needs to be able to customize it - func configureStatusCell(_ cell: TimelineStatusCollectionViewCell, id: String, state: StatusState) { + func configureStatusCell(_ cell: TimelineStatusCollectionViewCell, id: String, state: CollapseState) { cell.delegate = self if case .home = timeline { cell.showFollowedHashtags = true @@ -110,7 +110,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro } private func createDataSource() -> UICollectionViewDiffableDataSource { - let statusCell = UICollectionView.CellRegistration { [unowned self] cell, indexPath, item in + let statusCell = UICollectionView.CellRegistration { [unowned self] cell, indexPath, item in self.configureStatusCell(cell, id: item.0, state: item.1) } let gapCell = UICollectionView.CellRegistration { cell, indexPath, _ in @@ -463,7 +463,7 @@ extension TimelineViewController { enum Item: TimelineLikeCollectionViewItem { typealias TimelineItem = String // status ID - case status(id: String, state: StatusState) + case status(id: String, state: CollapseState) case gap case loadingIndicator case confirmLoadMore diff --git a/Tusker/TuskerNavigationDelegate.swift b/Tusker/TuskerNavigationDelegate.swift index 5d4e2bd9..5291377a 100644 --- a/Tusker/TuskerNavigationDelegate.swift +++ b/Tusker/TuskerNavigationDelegate.swift @@ -13,7 +13,7 @@ import Pachyderm protocol TuskerNavigationDelegate: UIViewController, ToastableViewController { var apiController: MastodonController! { get } - func conversation(mainStatusID: String, state: StatusState) -> ConversationTableViewController + func conversation(mainStatusID: String, state: CollapseState) -> ConversationTableViewController } extension TuskerNavigationDelegate { @@ -76,7 +76,7 @@ extension TuskerNavigationDelegate { } } - func conversation(mainStatusID: String, state: StatusState) -> ConversationTableViewController { + func conversation(mainStatusID: String, state: CollapseState) -> ConversationTableViewController { return ConversationTableViewController(for: mainStatusID, state: state, mastodonController: apiController) } @@ -84,7 +84,7 @@ extension TuskerNavigationDelegate { self.selected(status: statusID, state: .unknown) } - func selected(status statusID: String, state: StatusState) { + func selected(status statusID: String, state: CollapseState) { show(conversation(mainStatusID: statusID, state: state), sender: self) } @@ -183,7 +183,7 @@ extension TuskerNavigationDelegate { show(vc, sender: self) } - func statusActionAccountList(action: StatusActionAccountListViewController.ActionType, statusID: String, statusState state: StatusState, accountIDs: [String]?) -> StatusActionAccountListViewController { + func statusActionAccountList(action: StatusActionAccountListViewController.ActionType, statusID: String, statusState state: CollapseState, accountIDs: [String]?) -> StatusActionAccountListViewController { return StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: state, accountIDs: accountIDs, mastodonController: apiController) } diff --git a/Tusker/Views/Status/BaseStatusTableViewCell.swift b/Tusker/Views/Status/BaseStatusTableViewCell.swift index 43b9d6a3..d234f11d 100644 --- a/Tusker/Views/Status/BaseStatusTableViewCell.swift +++ b/Tusker/Views/Status/BaseStatusTableViewCell.swift @@ -57,7 +57,7 @@ class BaseStatusTableViewCell: UITableViewCell { } } - private(set) var statusState: StatusState! + private(set) var statusState: CollapseState! var collapsible = false { didSet { collapseButton.isHidden = !collapsible @@ -130,7 +130,7 @@ class BaseStatusTableViewCell: UITableViewCell { } } - final func updateUI(statusID: String, state: StatusState) { + final func updateUI(statusID: String, state: CollapseState) { createObserversIfNecessary() guard let status = mastodonController.persistentContainer.status(for: statusID) else { @@ -142,7 +142,7 @@ class BaseStatusTableViewCell: UITableViewCell { doUpdateUI(status: status, state: state) } - func doUpdateUI(status: StatusMO, state: StatusState) { + func doUpdateUI(status: StatusMO, state: CollapseState) { self.statusState = state let account = status.account diff --git a/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift b/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift index 53e5634f..186fdecf 100644 --- a/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift +++ b/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift @@ -80,7 +80,7 @@ class ConversationMainStatusTableViewCell: BaseStatusTableViewCell { timestampAndClientLabel.adjustsFontForContentSizeCategory = true } - override func doUpdateUI(status: StatusMO, state: StatusState) { + override func doUpdateUI(status: StatusMO, state: CollapseState) { super.doUpdateUI(status: status, state: state) var timestampAndClientText = ConversationMainStatusTableViewCell.dateFormatter.string(from: status.createdAt) diff --git a/Tusker/Views/Status/StatusCollectionViewCell.swift b/Tusker/Views/Status/StatusCollectionViewCell.swift index eb0ace0a..332adcbe 100644 --- a/Tusker/Views/Status/StatusCollectionViewCell.swift +++ b/Tusker/Views/Status/StatusCollectionViewCell.swift @@ -36,7 +36,7 @@ protocol StatusCollectionViewCell: UICollectionViewCell, AttachmentViewDelegate var showReplyIndicator: Bool { get } var statusID: String! { get set } - var statusState: StatusState! { get set } + var statusState: CollapseState! { get set } var accountID: String! { get set } var isGrayscale: Bool { get set } diff --git a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift index 505fdfd3..a733532f 100644 --- a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift @@ -265,7 +265,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti // alas these need to be internal so they're accessible from the protocol extensions var statusID: String! - var statusState: StatusState! + var statusState: CollapseState! var accountID: String! private var reblogStatusID: String? private var rebloggerID: String? @@ -422,7 +422,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti // MARK: Configure UI - func updateUI(statusID: String, state: StatusState) { + func updateUI(statusID: String, state: CollapseState) { guard var status = mastodonController.persistentContainer.status(for: statusID) else { fatalError() } diff --git a/Tusker/Views/Status/TimelineStatusTableViewCell.swift b/Tusker/Views/Status/TimelineStatusTableViewCell.swift index 632f3442..d80a98a3 100644 --- a/Tusker/Views/Status/TimelineStatusTableViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusTableViewCell.swift @@ -110,7 +110,7 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { } } - override func doUpdateUI(status: StatusMO, state: StatusState) { + override func doUpdateUI(status: StatusMO, state: CollapseState) { var status = status if let rebloggedStatus = status.reblog {