From 39adb439df1e541ac0588c2016aac72c35d21804 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Tue, 22 Nov 2022 21:28:28 +0100 Subject: [PATCH] chore: Cleanup and fixes (#663) --- .../SearchResultViewController.swift | 75 ------------------- .../SearchResultViewModel+State.swift | 4 +- 2 files changed, 2 insertions(+), 77 deletions(-) diff --git a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift index 6a840f9b5..564dd9579 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift @@ -52,7 +52,6 @@ extension SearchResultViewController { tableView.pinToParent() tableView.delegate = self -// tableView.prefetchDataSource = self viewModel.setupDiffableDataSource( tableView: tableView, statusTableViewCellDelegate: self @@ -142,10 +141,7 @@ extension SearchResultViewController { extension SearchResultViewController { private func setupBackgroundColor(theme: Theme) { view.backgroundColor = theme.systemGroupedBackgroundColor -// tableView.backgroundColor = theme.systemBackgroundColor -// searchHeader.backgroundColor = theme.systemGroupedBackgroundColor } - } // MARK: - StatusTableViewCellDelegate @@ -180,78 +176,7 @@ extension SearchResultViewController: UITableViewDelegate, AutoGenerateTableView } // sourcery:end - -// func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { -// aspectTableView(tableView, estimatedHeightForRowAt: indexPath) -// } -// -// func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { -// aspectTableView(tableView, willDisplay: cell, forRowAt: indexPath) -// } -// -// func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) { -// aspectTableView(tableView, didEndDisplaying: cell, forRowAt: indexPath) -// } -// -// func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { -// guard let diffableDataSource = viewModel.diffableDataSource else { return } -// guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return } -// -// viewModel.persistSearchHistory(for: item) -// -// switch item { -// case .account(let account): -// let profileViewModel = RemoteProfileViewModel(context: context, userID: account.id) -// coordinator.present(scene: .profile(viewModel: profileViewModel), from: self, transition: .show) -// case .hashtag(let hashtag): -// let hashtagViewModel = HashtagTimelineViewModel(context: context, hashtag: hashtag.name) -// coordinator.present(scene: .hashtagTimeline(viewModel: hashtagViewModel), from: self, transition: .show) -// case .status: -// aspectTableView(tableView, didSelectRowAt: indexPath) -// case .bottomLoader: -// break -// } -// } -// -// func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { -// aspectTableView(tableView, contextMenuConfigurationForRowAt: indexPath, point: point) -// } -// -// func tableView(_ tableView: UITableView, previewForHighlightingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? { -// aspectTableView(tableView, previewForHighlightingContextMenuWithConfiguration: configuration) -// } -// -// func tableView(_ tableView: UITableView, previewForDismissingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? { -// aspectTableView(tableView, previewForDismissingContextMenuWithConfiguration: configuration) -// } -// -// func tableView(_ tableView: UITableView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) { -// aspectTableView(tableView, willPerformPreviewActionForMenuWith: configuration, animator: animator) -// } - } -// MARK: - UITableViewDataSourcePrefetching -//extension SearchResultViewController: UITableViewDataSourcePrefetching { -// func tableView(_ tableView: UITableView, prefetchRowsAt indexPaths: [IndexPath]) { -// aspectTableView(tableView, cancelPrefetchingForRowsAt: indexPaths) -// } -// -// func tableView(_ tableView: UITableView, cancelPrefetchingForRowsAt indexPaths: [IndexPath]) { -// aspectTableView(tableView, cancelPrefetchingForRowsAt: indexPaths) -// } -//} - -// MARK: - AVPlayerViewControllerDelegate -//extension SearchResultViewController: AVPlayerViewControllerDelegate { -// func playerViewController(_ playerViewController: AVPlayerViewController, willBeginFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) { -// handlePlayerViewController(playerViewController, willBeginFullScreenPresentationWithAnimationCoordinator: coordinator) -// } -// -// func playerViewController(_ playerViewController: AVPlayerViewController, willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) { -// handlePlayerViewController(playerViewController, willEndFullScreenPresentationWithAnimationCoordinator: coordinator) -// } -//} - // MARK: - StatusTableViewCellDelegate extension SearchResultViewController: StatusTableViewCellDelegate { } diff --git a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel+State.swift b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel+State.swift index 9fc019587..563783423 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel+State.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel+State.swift @@ -36,7 +36,7 @@ extension SearchResultViewModel.State { class Initial: SearchResultViewModel.State { override func isValidNextState(_ stateClass: AnyClass) -> Bool { guard let viewModel = viewModel else { return false } - return stateClass == Loading.self && !viewModel.searchText.value.isEmpty + return stateClass == Loading.self && (viewModel.searchText.value.isEmpty == false) } } @@ -60,7 +60,7 @@ extension SearchResultViewModel.State { override func didEnter(from previousState: GKState?) { super.didEnter(from: previousState) - guard let viewModel = viewModel, let stateMachine = stateMachine else { return } + guard let viewModel, let stateMachine = stateMachine else { return } let searchText = viewModel.searchText.value let searchType = viewModel.searchScope.searchType