forked from zelo72/mastodon-ios
chore: renaming
This commit is contained in:
parent
1a60428f2a
commit
7705e54e67
|
@ -10,14 +10,14 @@ import Combine
|
||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
enum ComposeStatusItem {
|
enum ComposeStatusItem {
|
||||||
case replyTo(tootObjectID: NSManagedObjectID)
|
case replyTo(statusObjectID: NSManagedObjectID)
|
||||||
case toot(replyToTootObjectID: NSManagedObjectID?, attribute: ComposeTootAttribute)
|
case input(replyToStatusObjectID: NSManagedObjectID?, attribute: ComposeStatusAttribute)
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ComposeStatusItem: Hashable { }
|
extension ComposeStatusItem: Hashable { }
|
||||||
|
|
||||||
extension ComposeStatusItem {
|
extension ComposeStatusItem {
|
||||||
final class ComposeTootAttribute: Equatable, Hashable {
|
final class ComposeStatusAttribute: Equatable, Hashable {
|
||||||
private let id = UUID()
|
private let id = UUID()
|
||||||
|
|
||||||
let avatarURL = CurrentValueSubject<URL?, Never>(nil)
|
let avatarURL = CurrentValueSubject<URL?, Never>(nil)
|
||||||
|
@ -25,7 +25,7 @@ extension ComposeStatusItem {
|
||||||
let username = CurrentValueSubject<String?, Never>(nil)
|
let username = CurrentValueSubject<String?, Never>(nil)
|
||||||
let composeContent = CurrentValueSubject<String?, Never>(nil)
|
let composeContent = CurrentValueSubject<String?, Never>(nil)
|
||||||
|
|
||||||
static func == (lhs: ComposeTootAttribute, rhs: ComposeTootAttribute) -> Bool {
|
static func == (lhs: ComposeStatusAttribute, rhs: ComposeStatusAttribute) -> Bool {
|
||||||
return lhs.avatarURL.value == rhs.avatarURL.value &&
|
return lhs.avatarURL.value == rhs.avatarURL.value &&
|
||||||
lhs.displayName.value == rhs.displayName.value &&
|
lhs.displayName.value == rhs.displayName.value &&
|
||||||
lhs.username.value == rhs.username.value &&
|
lhs.username.value == rhs.username.value &&
|
||||||
|
|
|
@ -37,7 +37,7 @@ extension ComposeStatusSection {
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ComposeRepliedToTootContentTableViewCell.self), for: indexPath) as! ComposeRepliedToTootContentTableViewCell
|
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ComposeRepliedToTootContentTableViewCell.self), for: indexPath) as! ComposeRepliedToTootContentTableViewCell
|
||||||
// TODO:
|
// TODO:
|
||||||
return cell
|
return cell
|
||||||
case .toot(let replyToTootObjectID, let attribute):
|
case .input(let replyToTootObjectID, let attribute):
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ComposeTootContentTableViewCell.self), for: indexPath) as! ComposeTootContentTableViewCell
|
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ComposeTootContentTableViewCell.self), for: indexPath) as! ComposeTootContentTableViewCell
|
||||||
managedObjectContext.perform {
|
managedObjectContext.perform {
|
||||||
guard let replyToTootObjectID = replyToTootObjectID,
|
guard let replyToTootObjectID = replyToTootObjectID,
|
||||||
|
@ -67,7 +67,7 @@ extension ComposeStatusSection {
|
||||||
extension ComposeStatusSection {
|
extension ComposeStatusSection {
|
||||||
static func configure(
|
static func configure(
|
||||||
cell: ComposeTootContentTableViewCell,
|
cell: ComposeTootContentTableViewCell,
|
||||||
attribute: ComposeStatusItem.ComposeTootAttribute
|
attribute: ComposeStatusItem.ComposeStatusAttribute
|
||||||
) {
|
) {
|
||||||
// set avatar
|
// set avatar
|
||||||
attribute.avatarURL
|
attribute.avatarURL
|
||||||
|
|
|
@ -176,7 +176,7 @@ extension ComposeViewController {
|
||||||
let items = diffableDataSource.snapshot().itemIdentifiers
|
let items = diffableDataSource.snapshot().itemIdentifiers
|
||||||
for item in items {
|
for item in items {
|
||||||
switch item {
|
switch item {
|
||||||
case .toot:
|
case .input:
|
||||||
guard let indexPath = diffableDataSource.indexPath(for: item),
|
guard let indexPath = diffableDataSource.indexPath(for: item),
|
||||||
let cell = tableView.cellForRow(at: indexPath) as? ComposeTootContentTableViewCell else {
|
let cell = tableView.cellForRow(at: indexPath) as? ComposeTootContentTableViewCell else {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -26,11 +26,11 @@ extension ComposeViewModel {
|
||||||
var snapshot = NSDiffableDataSourceSnapshot<ComposeStatusSection, ComposeStatusItem>()
|
var snapshot = NSDiffableDataSourceSnapshot<ComposeStatusSection, ComposeStatusItem>()
|
||||||
snapshot.appendSections([.repliedTo, .status])
|
snapshot.appendSections([.repliedTo, .status])
|
||||||
switch composeKind {
|
switch composeKind {
|
||||||
case .reply(let tootObjectID):
|
case .reply(let statusObjectID):
|
||||||
snapshot.appendItems([.replyTo(tootObjectID: tootObjectID)], toSection: .repliedTo)
|
snapshot.appendItems([.replyTo(statusObjectID: statusObjectID)], toSection: .repliedTo)
|
||||||
snapshot.appendItems([.toot(replyToTootObjectID: tootObjectID, attribute: composeTootAttribute)], toSection: .status)
|
snapshot.appendItems([.input(replyToStatusObjectID: statusObjectID, attribute: composeStatusAttribute)], toSection: .repliedTo)
|
||||||
case .post:
|
case .post:
|
||||||
snapshot.appendItems([.toot(replyToTootObjectID: nil, attribute: composeTootAttribute)], toSection: .status)
|
snapshot.appendItems([.input(replyToStatusObjectID: nil, attribute: composeStatusAttribute)], toSection: .status)
|
||||||
}
|
}
|
||||||
diffableDataSource.apply(snapshot, animatingDifferences: false)
|
diffableDataSource.apply(snapshot, animatingDifferences: false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ final class ComposeViewModel {
|
||||||
// input
|
// input
|
||||||
let context: AppContext
|
let context: AppContext
|
||||||
let composeKind: ComposeStatusSection.ComposeKind
|
let composeKind: ComposeStatusSection.ComposeKind
|
||||||
let composeTootAttribute = ComposeStatusItem.ComposeTootAttribute()
|
let composeStatusAttribute = ComposeStatusItem.ComposeStatusAttribute()
|
||||||
let composeContent = CurrentValueSubject<String, Never>("")
|
let composeContent = CurrentValueSubject<String, Never>("")
|
||||||
let activeAuthentication: CurrentValueSubject<MastodonAuthentication?, Never>
|
let activeAuthentication: CurrentValueSubject<MastodonAuthentication?, Never>
|
||||||
|
|
||||||
|
|
|
@ -76,9 +76,9 @@ extension HomeTimelineViewController {
|
||||||
identifier: nil,
|
identifier: nil,
|
||||||
options: [],
|
options: [],
|
||||||
children: [50, 100, 150, 200, 250, 300].map { count in
|
children: [50, 100, 150, 200, 250, 300].map { count in
|
||||||
UIAction(title: "Drop Recent \(count) Toots", image: nil, attributes: [], handler: { [weak self] action in
|
UIAction(title: "Drop Recent \(count) Statuses", image: nil, attributes: [], handler: { [weak self] action in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
self.dropRecentTootsAction(action, count: count)
|
self.dropRecentStatusAction(action, count: count)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -118,11 +118,11 @@ extension HomeTimelineViewController {
|
||||||
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
|
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
|
||||||
tableView.blinkRow(at: IndexPath(row: index, section: 0))
|
tableView.blinkRow(at: IndexPath(row: index, section: 0))
|
||||||
} else {
|
} else {
|
||||||
print("Not found poll toot")
|
print("Not found status contains poll")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func dropRecentTootsAction(_ sender: UIAction, count: Int) {
|
@objc private func dropRecentStatusAction(_ sender: UIAction, count: Int) {
|
||||||
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
||||||
let snapshotTransitioning = diffableDataSource.snapshot()
|
let snapshotTransitioning = diffableDataSource.snapshot()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue