Rename StatusState to CollapseState

This commit is contained in:
Shadowfacts 2022-12-03 18:21:49 -05:00
parent fcf95ba8c1
commit cde3109203
17 changed files with 38 additions and 38 deletions

View File

@ -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
}
}

View File

@ -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 }

View File

@ -9,7 +9,7 @@
import Foundation
import Pachyderm
extension StatusState {
extension CollapseState {
func resolveFor(status: StatusMO, height: CGFloat, textLength: Int? = nil) {
let longEnoughToCollapse: Bool

View File

@ -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?

View File

@ -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<Section, Item>!
@ -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

View File

@ -62,7 +62,7 @@ class TrendingStatusesViewController: UIViewController {
}
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, StatusState)> { [unowned self] cell, indexPath, item in
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, CollapseState)> { [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 {

View File

@ -110,7 +110,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
collectionView.register(ProfileHeaderCollectionViewCell.self, forCellWithReuseIdentifier: "headerCell")
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, StatusState, Bool)> { [unowned self] cell, indexPath, item in
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, CollapseState, Bool)> { [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

View File

@ -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 {

View File

@ -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

View File

@ -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)

View File

@ -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<Section, Item> {
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, StatusState)> { [unowned self] cell, indexPath, item in
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, CollapseState)> { [unowned self] cell, indexPath, item in
self.configureStatusCell(cell, id: item.0, state: item.1)
}
let gapCell = UICollectionView.CellRegistration<TimelineGapCollectionViewCell, Void> { 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

View File

@ -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)
}

View File

@ -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

View File

@ -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)

View File

@ -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 }

View File

@ -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()
}

View File

@ -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 {