Remove dead code (IOS-245)

This commit is contained in:
Nathan Mattes 2024-04-16 09:56:41 +02:00
parent 693e0ede54
commit cc4fc05997
2 changed files with 5 additions and 32 deletions

View File

@ -25,7 +25,6 @@ final class AccountListViewModel: NSObject {
// output
@Published var items: [Item] = []
let dataSourceDidUpdate = PassthroughSubject<Void, Never>()
var diffableDataSource: UITableViewDiffableDataSource<Section, Item>!
init(context: AppContext, authContext: AuthContext) {
@ -50,9 +49,7 @@ final class AccountListViewModel: NSObject {
snapshot.appendItems([.addAccount], toSection: .main)
snapshot.appendItems([.logoutOfAllAccounts], toSection: .main)
diffableDataSource.apply(snapshot) {
self.dataSourceDidUpdate.send()
}
diffableDataSource.apply(snapshot)
}
.store(in: &disposeBag)
}
@ -70,10 +67,7 @@ extension AccountListViewModel {
case logoutOfAllAccounts
}
func setupDiffableDataSource(
tableView: UITableView,
managedObjectContext: NSManagedObjectContext
) {
func setupDiffableDataSource(tableView: UITableView) {
diffableDataSource = UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item in
switch item {
case .authentication(let record):
@ -81,7 +75,6 @@ extension AccountListViewModel {
if let activeAuthentication = AuthenticationServiceProvider.shared.authenticationSortedByActivation().first
{
AccountListViewModel.configure(
in: managedObjectContext,
cell: cell,
authentication: record,
activeAuthentication: activeAuthentication
@ -103,7 +96,6 @@ extension AccountListViewModel {
}
static func configure(
in context: NSManagedObjectContext,
cell: AccountListTableViewCell,
authentication: MastodonAuthentication,
activeAuthentication: MastodonAuthentication

View File

@ -76,26 +76,7 @@ extension AccountListViewController {
])
tableView.delegate = self
viewModel.setupDiffableDataSource(
tableView: tableView,
managedObjectContext: context.managedObjectContext
)
viewModel.dataSourceDidUpdate
.receive(on: DispatchQueue.main)
.sink { [weak self, weak presentingViewController] in
guard let self = self else { return }
// the presentingViewController may deinit.
// Hold it and check the window to prevent PanModel crash
guard let _ = presentingViewController else { return }
guard self.view.window != nil else { return }
self.hasLoaded = true
self.panModalSetNeedsLayoutUpdate() // <<< may crash the app
self.panModalTransition(to: .shortForm)
}
.store(in: &disposeBag)
viewModel.setupDiffableDataSource(tableView: tableView)
}
}
@ -117,8 +98,8 @@ extension AccountListViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
guard let diffableDataSource = viewModel.diffableDataSource else { return }
guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return }
guard let diffableDataSource = viewModel.diffableDataSource,
let item = diffableDataSource.itemIdentifier(for: indexPath) else { return }
switch item {
case .authentication(let record):