From 48c7ffe20ea7cfadbc88e2ed052b9f48bf7c4219 Mon Sep 17 00:00:00 2001 From: CMK Date: Thu, 24 Jun 2021 15:14:50 +0800 Subject: [PATCH] fix: paging still enabled issue when blocking/blocked in profile scene --- Mastodon/Scene/Profile/ProfileViewController.swift | 10 +++++++++- Mastodon/Scene/Profile/ProfileViewModel.swift | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Mastodon/Scene/Profile/ProfileViewController.swift b/Mastodon/Scene/Profile/ProfileViewController.swift index 8ba7851c..57b677a7 100644 --- a/Mastodon/Scene/Profile/ProfileViewController.swift +++ b/Mastodon/Scene/Profile/ProfileViewController.swift @@ -452,7 +452,7 @@ extension ProfileViewController { viewModel.isEditing .handleEvents(receiveOutput: { [weak self] isEditing in guard let self = self else { return } - // set firset responder for key command + // set first responder for key command if !isEditing { DispatchQueue.main.asyncAfter(deadline: .now() + 1) { self.profileSegmentedViewController.pagingViewController.becomeFirstResponder() @@ -520,6 +520,14 @@ extension ProfileViewController { self.profileHeaderViewController.profileHeaderView.statusDashboardView.followersDashboardMeterView.accessibilityLabel = L10n.Scene.Profile.Dashboard.Accessibility.countFollowers(count ?? 0) } .store(in: &disposeBag) + viewModel.needsPaingEnabled + .receive(on: RunLoop.main) + .sink { [weak self] needsPaingEnabled in + guard let self = self else { return } + self.profileSegmentedViewController.pagingViewController.isScrollEnabled = needsPaingEnabled + } + .store(in: &disposeBag) + profileHeaderViewController.profileHeaderView.delegate = self } diff --git a/Mastodon/Scene/Profile/ProfileViewModel.swift b/Mastodon/Scene/Profile/ProfileViewModel.swift index 619d55ba..2d4bc429 100644 --- a/Mastodon/Scene/Profile/ProfileViewModel.swift +++ b/Mastodon/Scene/Profile/ProfileViewModel.swift @@ -58,8 +58,9 @@ class ProfileViewModel: NSObject { let isReplyBarButtonItemHidden = CurrentValueSubject(true) let isMoreMenuBarButtonItemHidden = CurrentValueSubject(true) let isMeBarButtonItemsHidden = CurrentValueSubject(true) - + let needsPagePinToTop = CurrentValueSubject(false) + let needsPaingEnabled = CurrentValueSubject(true) init(context: AppContext, optionalMastodonUser mastodonUser: MastodonUser?) { self.context = context @@ -147,6 +148,14 @@ class ProfileViewModel: NSObject { } .store(in: &disposeBag) + Publishers.CombineLatest( + isBlocking, + isBlockedBy + ) + .map { !($0 || $1) } + .assign(to: \.value, on: needsPaingEnabled) + .store(in: &disposeBag) + setup() }