From 206beb6d19d46fc71f4b62ee8b79eedb37dd655d Mon Sep 17 00:00:00 2001 From: CMK Date: Tue, 2 Nov 2021 16:00:42 +0800 Subject: [PATCH] chore: update following/follower list footer display logic --- .../Follower/FollowerListViewModel+Diffable.swift | 6 +++++- .../Follower/FollowerListViewModel+State.swift | 2 +- .../Following/FollowingListViewModel+Diffable.swift | 7 ++++++- .../Following/FollowingListViewModel+State.swift | 12 ------------ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Mastodon/Scene/Profile/Follower/FollowerListViewModel+Diffable.swift b/Mastodon/Scene/Profile/Follower/FollowerListViewModel+Diffable.swift index c048e1723..fc9f31779 100644 --- a/Mastodon/Scene/Profile/Follower/FollowerListViewModel+Diffable.swift +++ b/Mastodon/Scene/Profile/Follower/FollowerListViewModel+Diffable.swift @@ -48,7 +48,11 @@ extension FollowerListViewModel { case is State.Idle, is State.Loading, is State.Fail: snapshot.appendItems([.bottomLoader], toSection: .main) case is State.NoMore: - let text = "Followers from other servers are not displayed." + guard let activeMastodonAuthenticationBox = self.context.authenticationService.activeMastodonAuthenticationBox.value, + let userID = self.userID.value, + userID != activeMastodonAuthenticationBox.userID + else { break } + let text = L10n.Scene.Follower.footer snapshot.appendItems([.bottomHeader(text: text)], toSection: .main) default: break diff --git a/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift b/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift index 876933181..30621f6a3 100644 --- a/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift +++ b/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift @@ -155,7 +155,7 @@ extension FollowerListViewModel.State { let maxID = response.link?.maxID - if hasNewAppend, maxID != nil { + if maxID != nil { stateMachine.enter(Idle.self) } else { stateMachine.enter(NoMore.self) diff --git a/Mastodon/Scene/Profile/Following/FollowingListViewModel+Diffable.swift b/Mastodon/Scene/Profile/Following/FollowingListViewModel+Diffable.swift index 58af276d0..dc6f1f6fd 100644 --- a/Mastodon/Scene/Profile/Following/FollowingListViewModel+Diffable.swift +++ b/Mastodon/Scene/Profile/Following/FollowingListViewModel+Diffable.swift @@ -48,7 +48,12 @@ extension FollowingListViewModel { case is State.Idle, is State.Loading, is State.Fail: snapshot.appendItems([.bottomLoader], toSection: .main) case is State.NoMore: - break + guard let activeMastodonAuthenticationBox = self.context.authenticationService.activeMastodonAuthenticationBox.value, + let userID = self.userID.value, + userID != activeMastodonAuthenticationBox.userID + else { break } + let text = L10n.Scene.Following.footer + snapshot.appendItems([.bottomHeader(text: text)], toSection: .main) default: break } diff --git a/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift b/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift index d5c30b43a..e6fadf7f8 100644 --- a/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift +++ b/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift @@ -179,18 +179,6 @@ extension FollowingListViewModel.State { override func didEnter(from previousState: GKState?) { super.didEnter(from: previousState) - guard let viewModel = viewModel, let _ = stateMachine else { return } - guard let diffableDataSource = viewModel.diffableDataSource else { - assertionFailure() - return - } - DispatchQueue.main.async { - var snapshot = diffableDataSource.snapshot() - snapshot.deleteItems([.bottomLoader]) - let header = UserItem.bottomHeader(text: "Followers from other servers are not displayed") - snapshot.appendItems([header], toSection: .main) - diffableDataSource.apply(snapshot, animatingDifferences: false) - } } } }