chore: add debug entries

This commit is contained in:
CMK 2021-03-16 11:48:14 +08:00
parent 1c6f231fee
commit 1a3cff8a3a
1 changed files with 88 additions and 27 deletions

View File

@ -45,34 +45,30 @@ extension HomeTimelineViewController {
guard let self = self else { return } guard let self = self else { return }
self.moveToTopGapAction(action) self.moveToTopGapAction(action)
}), }),
UIAction(title: "First Reblog Toot", image: nil, attributes: [], handler: { [weak self] action in UIAction(title: "First Replied Status", image: nil, attributes: [], handler: { [weak self] action in
guard let self = self else { return } guard let self = self else { return }
self.moveToFirstReblogToot(action) self.moveToFirstRepliedStatus(action)
}), }),
UIAction(title: "First Poll Toot", image: nil, attributes: [], handler: { [weak self] action in UIAction(title: "First Reblog Status", image: nil, attributes: [], handler: { [weak self] action in
guard let self = self else { return } guard let self = self else { return }
self.moveToFirstPollToot(action) self.moveToFirstReblogStatus(action)
}), }),
UIAction(title: "First Audio Toot", image: nil, attributes: [], handler: { [weak self] action in UIAction(title: "First Poll Status", image: nil, attributes: [], handler: { [weak self] action in
guard let self = self else { return } guard let self = self else { return }
self.moveToFirstAudioToot(action) self.moveToFirstPollStatus(action)
}),
UIAction(title: "First Audio Status", image: nil, attributes: [], handler: { [weak self] action in
guard let self = self else { return }
self.moveToFirstAudioStatus(action)
}),
UIAction(title: "First Video Status", image: nil, attributes: [], handler: { [weak self] action in
guard let self = self else { return }
self.moveToFirstVideoStatus(action)
}),
UIAction(title: "First GIF Toot", image: nil, attributes: [], handler: { [weak self] action in
guard let self = self else { return }
self.moveToFirstGIFStatus(action)
}), }),
// UIAction(title: "First Reply Toot", image: nil, attributes: [], handler: { [weak self] action in
// guard let self = self else { return }
// self.moveToFirstReplyToot(action)
// }),
// UIAction(title: "First Reply Reblog", image: nil, attributes: [], handler: { [weak self] action in
// guard let self = self else { return }
// self.moveToFirstReplyReblog(action)
// }),
// UIAction(title: "First Video Toot", image: nil, attributes: [], handler: { [weak self] action in
// guard let self = self else { return }
// self.moveToFirstVideoToot(action)
// }),
// UIAction(title: "First GIF Toot", image: nil, attributes: [], handler: { [weak self] action in
// guard let self = self else { return }
// self.moveToFirstGIFToot(action)
// }),
] ]
) )
} }
@ -109,7 +105,7 @@ extension HomeTimelineViewController {
} }
} }
@objc private func moveToFirstReblogToot(_ sender: UIAction) { @objc private func moveToFirstReblogStatus(_ sender: UIAction) {
guard let diffableDataSource = viewModel.diffableDataSource else { return } guard let diffableDataSource = viewModel.diffableDataSource else { return }
let snapshotTransitioning = diffableDataSource.snapshot() let snapshotTransitioning = diffableDataSource.snapshot()
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
@ -125,11 +121,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 reblog toot") print("Not found reblog status")
} }
} }
@objc private func moveToFirstPollToot(_ sender: UIAction) { @objc private func moveToFirstPollStatus(_ sender: UIAction) {
guard let diffableDataSource = viewModel.diffableDataSource else { return } guard let diffableDataSource = viewModel.diffableDataSource else { return }
let snapshotTransitioning = diffableDataSource.snapshot() let snapshotTransitioning = diffableDataSource.snapshot()
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
@ -146,11 +142,34 @@ 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 poll status")
} }
} }
@objc private func moveToFirstAudioToot(_ sender: UIAction) { @objc private func moveToFirstRepliedStatus(_ sender: UIAction) {
guard let diffableDataSource = viewModel.diffableDataSource else { return }
let snapshotTransitioning = diffableDataSource.snapshot()
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
switch item {
case .homeTimelineIndex(let objectID, _):
let homeTimelineIndex = viewModel.fetchedResultsController.managedObjectContext.object(with: objectID) as! HomeTimelineIndex
guard homeTimelineIndex.toot.inReplyToID != nil else {
return false
}
return true
default:
return false
}
})
if let targetItem = item, let index = snapshotTransitioning.indexOfItem(targetItem) {
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
tableView.blinkRow(at: IndexPath(row: index, section: 0))
} else {
print("Not found replied status")
}
}
@objc private func moveToFirstAudioStatus(_ sender: UIAction) {
guard let diffableDataSource = viewModel.diffableDataSource else { return } guard let diffableDataSource = viewModel.diffableDataSource else { return }
let snapshotTransitioning = diffableDataSource.snapshot() let snapshotTransitioning = diffableDataSource.snapshot()
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
@ -171,6 +190,48 @@ extension HomeTimelineViewController {
} }
} }
@objc private func moveToFirstVideoStatus(_ sender: UIAction) {
guard let diffableDataSource = viewModel.diffableDataSource else { return }
let snapshotTransitioning = diffableDataSource.snapshot()
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
switch item {
case .homeTimelineIndex(let objectID, _):
let homeTimelineIndex = viewModel.fetchedResultsController.managedObjectContext.object(with: objectID) as! HomeTimelineIndex
let toot = homeTimelineIndex.toot.reblog ?? homeTimelineIndex.toot
return toot.mediaAttachments?.contains(where: { $0.type == .video }) ?? false
default:
return false
}
})
if let targetItem = item, let index = snapshotTransitioning.indexOfItem(targetItem) {
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
tableView.blinkRow(at: IndexPath(row: index, section: 0))
} else {
print("Not found video status")
}
}
@objc private func moveToFirstGIFStatus(_ sender: UIAction) {
guard let diffableDataSource = viewModel.diffableDataSource else { return }
let snapshotTransitioning = diffableDataSource.snapshot()
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
switch item {
case .homeTimelineIndex(let objectID, _):
let homeTimelineIndex = viewModel.fetchedResultsController.managedObjectContext.object(with: objectID) as! HomeTimelineIndex
let toot = homeTimelineIndex.toot.reblog ?? homeTimelineIndex.toot
return toot.mediaAttachments?.contains(where: { $0.type == .gifv }) ?? false
default:
return false
}
})
if let targetItem = item, let index = snapshotTransitioning.indexOfItem(targetItem) {
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
tableView.blinkRow(at: IndexPath(row: index, section: 0))
} else {
print("Not found GIF status")
}
}
@objc private func dropRecentTootsAction(_ sender: UIAction, count: Int) { @objc private func dropRecentTootsAction(_ 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()