mastodon-ios/Mastodon/Scene/Profile/Bookmark/BookmarkViewController+Data...

35 lines
945 B
Swift

//
// BookmarkViewController+DataSourceProvider.swift
// Mastodon
//
// Created by ProtoLimit on 2022-07-19.
//
import UIKit
extension BookmarkViewController: DataSourceProvider {
func item(from source: DataSourceItem.Source) async -> DataSourceItem? {
var _indexPath = source.indexPath
if _indexPath == nil, let cell = source.tableViewCell {
_indexPath = await self.indexPath(for: cell)
}
guard let indexPath = _indexPath else { return nil }
guard let item = viewModel.diffableDataSource?.itemIdentifier(for: indexPath) else {
return nil
}
switch item {
case .status(let record):
return .status(record: record)
default:
return nil
}
}
@MainActor
private func indexPath(for cell: UITableViewCell) async -> IndexPath? {
return tableView.indexPath(for: cell)
}
}