diff --git a/Mastodon/Scene/Search/SearchDetail/Search Results Overview/SearchResultsOverviewTableViewController.swift b/Mastodon/Scene/Search/SearchDetail/Search Results Overview/SearchResultsOverviewTableViewController.swift index 797bd65e6..c6d6175c7 100644 --- a/Mastodon/Scene/Search/SearchDetail/Search Results Overview/SearchResultsOverviewTableViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/Search Results Overview/SearchResultsOverviewTableViewController.swift @@ -5,17 +5,8 @@ import MastodonCore import MastodonSDK import MastodonLocalization -protocol SearchResultsOverviewTableViewControllerDeleagte: AnyObject { - func showPeople(_ viewController: UIViewController) - func showProfile(_ viewController: UIViewController) - func openLink(_ viewController: UIViewController) -} - // we could move lots of this stuff to a coordinator, it's too much for work a viewcontroller class SearchResultsOverviewTableViewController: UIViewController, NeedsDependency, AuthContextProvider { - // similar to the other search results view controller but without the whole statemachine bullshit - // with scope all - var context: AppContext! let authContext: AuthContext var coordinator: SceneCoordinator! @@ -23,7 +14,6 @@ class SearchResultsOverviewTableViewController: UIViewController, NeedsDependenc private let tableView: UITableView var dataSource: UITableViewDiffableDataSource? - weak var delegate: SearchResultsOverviewTableViewControllerDeleagte? var activeTask: Task? init(appContext: AppContext, authContext: AuthContext, coordinator: SceneCoordinator) { @@ -330,7 +320,6 @@ class SearchResultsOverviewTableViewController: UIViewController, NeedsDependenc extension SearchResultsOverviewTableViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - //TODO: Implement properly! guard let snapshot = dataSource?.snapshot() else { return } let section = snapshot.sectionIdentifiers[indexPath.section] let item = snapshot.itemIdentifiers(inSection: section)[indexPath.row] diff --git a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift index e0f099bbe..990dab66e 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift @@ -115,8 +115,6 @@ final class SearchDetailViewController: UIViewController, NeedsDependency { searchHistoryViewController.view.pinToParent() } - searchResultsOverviewViewController.delegate = self - addChild(searchResultsOverviewViewController) searchResultsOverviewViewController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(searchResultsOverviewViewController.view) @@ -261,18 +259,3 @@ extension SearchDetailViewController: UISearchBarDelegate { } } } - -//MARK: SearchResultsOverviewViewControllerDelegate -extension SearchDetailViewController: SearchResultsOverviewTableViewControllerDeleagte { - func showPeople(_ viewController: UIViewController) { - //TODO: Implement - } - - func showProfile(_ viewController: UIViewController) { - //TODO: Implement - } - - func openLink(_ viewController: UIViewController) { - //TODO: Implement - } -} diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell+ViewModel.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell+ViewModel.swift index 31350811d..8e9710e9a 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell+ViewModel.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell+ViewModel.swift @@ -54,7 +54,9 @@ extension SearchHistoryUserCollectionViewCell { ) .receive(on: DispatchQueue.main) .sink { [weak self] followed, requested, blocked in - if blocked.contains(user.id) { + if user == me { + self?.userView.setButtonState(.none) + } else if blocked.contains(user.id) { self?.userView.setButtonState(.blocked) } else if followed.contains(user.id) { self?.userView.setButtonState(.unfollow) @@ -67,6 +69,5 @@ extension SearchHistoryUserCollectionViewCell { } } .store(in: &_disposeBag) - } } diff --git a/Mastodon/Scene/Share/View/TableviewCell/UserTableViewCell+ViewModel.swift b/Mastodon/Scene/Share/View/TableviewCell/UserTableViewCell+ViewModel.swift index 7f2727a91..526e74ab3 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/UserTableViewCell+ViewModel.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/UserTableViewCell+ViewModel.swift @@ -54,7 +54,9 @@ extension UserTableViewCell { ) .receive(on: DispatchQueue.main) .sink { [weak self] followed, requested, blocked in - if blocked.contains(viewModel.user.id) { + if viewModel.user == me { + self?.userView.setButtonState(.none) + } else if blocked.contains(viewModel.user.id) { self?.userView.setButtonState(.blocked) } else if followed.contains(viewModel.user.id) { self?.userView.setButtonState(.unfollow) diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/UserView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/View/Content/UserView+ViewModel.swift index 1b9a88772..4127ed4d4 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/UserView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/UserView+ViewModel.swift @@ -6,7 +6,6 @@ // import CoreDataStack -import os.log import UIKit import Combine import MetaTextKit @@ -19,9 +18,7 @@ extension UserView { public final class ViewModel: ObservableObject { public var disposeBag = Set() public var observations = Set() - - let logger = Logger(subsystem: "StatusView", category: "ViewModel") - + @Published public var authorAvatarImage: UIImage? @Published public var authorAvatarImageURL: URL? @Published public var authorName: MetaContent? diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/UserView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/UserView.swift index 2ea1f1a1f..9221c7f90 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/UserView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/UserView.swift @@ -261,41 +261,48 @@ public extension UserView { switch state { case .loading: + followButtonWrapper.isHidden = false followButton.isHidden = false followButton.setTitle(nil, for: .normal) followButton.setBackgroundColor(Asset.Colors.Button.disabled.color, for: .normal) case .follow: + followButtonWrapper.isHidden = false followButton.isHidden = false followButton.setTitle(L10n.Common.Controls.Friendship.follow, for: .normal) followButton.setBackgroundColor(Asset.Colors.Button.userFollow.color, for: .normal) followButton.setTitleColor(.white, for: .normal) case .request: + followButtonWrapper.isHidden = false followButton.isHidden = false followButton.setTitle(L10n.Common.Controls.Friendship.request, for: .normal) followButton.setBackgroundColor(Asset.Colors.Button.userFollow.color, for: .normal) followButton.setTitleColor(.white, for: .normal) case .pending: + followButtonWrapper.isHidden = false followButton.isHidden = false followButton.setTitle(L10n.Common.Controls.Friendship.pending, for: .normal) followButton.setTitleColor(Asset.Colors.Button.userFollowingTitle.color, for: .normal) followButton.setBackgroundColor(Asset.Colors.Button.userFollowing.color, for: .normal) case .unfollow: + followButtonWrapper.isHidden = false followButton.isHidden = false followButton.setTitle(L10n.Common.Controls.Friendship.following, for: .normal) followButton.setBackgroundColor(Asset.Colors.Button.userFollowing.color, for: .normal) followButton.setTitleColor(Asset.Colors.Button.userFollowingTitle.color, for: .normal) case .blocked: + followButtonWrapper.isHidden = false followButton.isHidden = false followButton.setTitle(L10n.Common.Controls.Friendship.blocked, for: .normal) followButton.setBackgroundColor(Asset.Colors.Button.userBlocked.color, for: .normal) followButton.setTitleColor(.systemRed, for: .normal) case .none: + followButtonWrapper.isHidden = true followButton.isHidden = true followButton.setTitle(nil, for: .normal) followButton.setBackgroundColor(.clear, for: .normal)