Revert FollowedBlockedUserIdProviding (IOS-140)
This commit is contained in:
parent
c7c635d32a
commit
5efdb3c209
|
@ -22,7 +22,6 @@
|
||||||
164F0EBC267D4FE400249499 /* BoopSound.caf in Resources */ = {isa = PBXBuildFile; fileRef = 164F0EBB267D4FE400249499 /* BoopSound.caf */; };
|
164F0EBC267D4FE400249499 /* BoopSound.caf in Resources */ = {isa = PBXBuildFile; fileRef = 164F0EBB267D4FE400249499 /* BoopSound.caf */; };
|
||||||
18BC7629F65E6DB12CB8416D /* Pods_Mastodon_MastodonUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C030226D3C73DCC23D67452 /* Pods_Mastodon_MastodonUITests.framework */; };
|
18BC7629F65E6DB12CB8416D /* Pods_Mastodon_MastodonUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C030226D3C73DCC23D67452 /* Pods_Mastodon_MastodonUITests.framework */; };
|
||||||
27D701F5292FC2D60031BCBB /* DataSourceFacade+URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D701F4292FC2D60031BCBB /* DataSourceFacade+URL.swift */; };
|
27D701F5292FC2D60031BCBB /* DataSourceFacade+URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D701F4292FC2D60031BCBB /* DataSourceFacade+URL.swift */; };
|
||||||
2A15964E2A09012300C603BE /* FollowedBlockedUserIdProviding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A15964D2A09012300C603BE /* FollowedBlockedUserIdProviding.swift */; };
|
|
||||||
2A1BF99529F7E68400FA1BA5 /* DataSourceFacade+UserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1BF99429F7E68400FA1BA5 /* DataSourceFacade+UserView.swift */; };
|
2A1BF99529F7E68400FA1BA5 /* DataSourceFacade+UserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1BF99429F7E68400FA1BA5 /* DataSourceFacade+UserView.swift */; };
|
||||||
2A1FE47C2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1FE47B2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift */; };
|
2A1FE47C2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1FE47B2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift */; };
|
||||||
2A1FE47E2938C11200784BF1 /* Collection+IsNotEmpty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */; };
|
2A1FE47E2938C11200784BF1 /* Collection+IsNotEmpty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */; };
|
||||||
|
@ -618,7 +617,6 @@
|
||||||
164F0EBB267D4FE400249499 /* BoopSound.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = BoopSound.caf; sourceTree = "<group>"; };
|
164F0EBB267D4FE400249499 /* BoopSound.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = BoopSound.caf; sourceTree = "<group>"; };
|
||||||
1D6D967E77A5357E2C6110D9 /* Pods-Mastodon.asdk - debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mastodon.asdk - debug.xcconfig"; path = "Target Support Files/Pods-Mastodon/Pods-Mastodon.asdk - debug.xcconfig"; sourceTree = "<group>"; };
|
1D6D967E77A5357E2C6110D9 /* Pods-Mastodon.asdk - debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mastodon.asdk - debug.xcconfig"; path = "Target Support Files/Pods-Mastodon/Pods-Mastodon.asdk - debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
27D701F4292FC2D60031BCBB /* DataSourceFacade+URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataSourceFacade+URL.swift"; sourceTree = "<group>"; };
|
27D701F4292FC2D60031BCBB /* DataSourceFacade+URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataSourceFacade+URL.swift"; sourceTree = "<group>"; };
|
||||||
2A15964D2A09012300C603BE /* FollowedBlockedUserIdProviding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowedBlockedUserIdProviding.swift; sourceTree = "<group>"; };
|
|
||||||
2A1BF99429F7E68400FA1BA5 /* DataSourceFacade+UserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataSourceFacade+UserView.swift"; sourceTree = "<group>"; };
|
2A1BF99429F7E68400FA1BA5 /* DataSourceFacade+UserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataSourceFacade+UserView.swift"; sourceTree = "<group>"; };
|
||||||
2A1FE47B2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FollowedTagsViewModel+DiffableDataSource.swift"; sourceTree = "<group>"; };
|
2A1FE47B2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FollowedTagsViewModel+DiffableDataSource.swift"; sourceTree = "<group>"; };
|
||||||
2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Collection+IsNotEmpty.swift"; sourceTree = "<group>"; };
|
2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Collection+IsNotEmpty.swift"; sourceTree = "<group>"; };
|
||||||
|
@ -2705,7 +2703,6 @@
|
||||||
DBCC3B8E26148F7B0045B23D /* CachedProfileViewModel.swift */,
|
DBCC3B8E26148F7B0045B23D /* CachedProfileViewModel.swift */,
|
||||||
DBAE3FAE26172FC0004B8251 /* RemoteProfileViewModel.swift */,
|
DBAE3FAE26172FC0004B8251 /* RemoteProfileViewModel.swift */,
|
||||||
DBB525632612C988002F1F29 /* MeProfileViewModel.swift */,
|
DBB525632612C988002F1F29 /* MeProfileViewModel.swift */,
|
||||||
2A15964D2A09012300C603BE /* FollowedBlockedUserIdProviding.swift */,
|
|
||||||
);
|
);
|
||||||
path = Profile;
|
path = Profile;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -3882,7 +3879,6 @@
|
||||||
DB1D84382657B275000346B3 /* SegmentedControlNavigateable.swift in Sources */,
|
DB1D84382657B275000346B3 /* SegmentedControlNavigateable.swift in Sources */,
|
||||||
0F20220726134DA4000C64BF /* HashtagTimelineViewModel+Diffable.swift in Sources */,
|
0F20220726134DA4000C64BF /* HashtagTimelineViewModel+Diffable.swift in Sources */,
|
||||||
DB7A9F932818F33C0016AF98 /* MastodonServerRulesViewController+Debug.swift in Sources */,
|
DB7A9F932818F33C0016AF98 /* MastodonServerRulesViewController+Debug.swift in Sources */,
|
||||||
2A15964E2A09012300C603BE /* FollowedBlockedUserIdProviding.swift in Sources */,
|
|
||||||
2D5A3D2825CF8BC9002347D6 /* HomeTimelineViewModel+Diffable.swift in Sources */,
|
2D5A3D2825CF8BC9002347D6 /* HomeTimelineViewModel+Diffable.swift in Sources */,
|
||||||
DB6B74FC272FF55800C70B6E /* UserSection.swift in Sources */,
|
DB6B74FC272FF55800C70B6E /* UserSection.swift in Sources */,
|
||||||
DB0FCB862796BDA1006C02E2 /* SearchSection.swift in Sources */,
|
DB0FCB862796BDA1006C02E2 /* SearchSection.swift in Sources */,
|
||||||
|
|
|
@ -32,7 +32,7 @@ extension SearchHistorySection {
|
||||||
guard let user = item.object(in: context.managedObjectContext) else { return }
|
guard let user = item.object(in: context.managedObjectContext) else { return }
|
||||||
cell.configure(
|
cell.configure(
|
||||||
me: authContext.mastodonAuthenticationBox.authenticationRecord.object(in: context.managedObjectContext)?.user,
|
me: authContext.mastodonAuthenticationBox.authenticationRecord.object(in: context.managedObjectContext)?.user,
|
||||||
viewModel: .init(value: user, followedUsers: viewModel.followedUserIds.eraseToAnyPublisher(), blockedUsers: viewModel.blockedUserIds.eraseToAnyPublisher()),
|
viewModel: .init(value: user, followedUsers: authContext.mastodonAuthenticationBox.inMemoryCache.$followingUserIds.eraseToAnyPublisher(), blockedUsers: authContext.mastodonAuthenticationBox.inMemoryCache.$blockedUserIds.eraseToAnyPublisher()),
|
||||||
delegate: configuration.searchHistorySectionHeaderCollectionReusableViewDelegate
|
delegate: configuration.searchHistorySectionHeaderCollectionReusableViewDelegate
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,7 @@ extension SearchResultSection {
|
||||||
tableView: UITableView,
|
tableView: UITableView,
|
||||||
context: AppContext,
|
context: AppContext,
|
||||||
authContext: AuthContext,
|
authContext: AuthContext,
|
||||||
configuration: Configuration,
|
configuration: Configuration
|
||||||
followedUsers: AnyPublisher<[String], Never>,
|
|
||||||
blockedUsers: AnyPublisher<[String], Never>
|
|
||||||
) -> UITableViewDiffableDataSource<SearchResultSection, SearchResultItem> {
|
) -> UITableViewDiffableDataSource<SearchResultSection, SearchResultItem> {
|
||||||
tableView.register(UserTableViewCell.self, forCellReuseIdentifier: String(describing: UserTableViewCell.self))
|
tableView.register(UserTableViewCell.self, forCellReuseIdentifier: String(describing: UserTableViewCell.self))
|
||||||
tableView.register(StatusTableViewCell.self, forCellReuseIdentifier: String(describing: StatusTableViewCell.self))
|
tableView.register(StatusTableViewCell.self, forCellReuseIdentifier: String(describing: StatusTableViewCell.self))
|
||||||
|
@ -55,7 +53,7 @@ extension SearchResultSection {
|
||||||
authContext: authContext,
|
authContext: authContext,
|
||||||
tableView: tableView,
|
tableView: tableView,
|
||||||
cell: cell,
|
cell: cell,
|
||||||
viewModel: .init(value: .user(user), followedUsers: followedUsers, blockedUsers: blockedUsers),
|
viewModel: .init(value: .user(user), followedUsers: authContext.mastodonAuthenticationBox.inMemoryCache.$followingUserIds.eraseToAnyPublisher(), blockedUsers: authContext.mastodonAuthenticationBox.inMemoryCache.$blockedUserIds.eraseToAnyPublisher()),
|
||||||
configuration: configuration
|
configuration: configuration
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,7 @@ extension UserSection {
|
||||||
tableView: UITableView,
|
tableView: UITableView,
|
||||||
context: AppContext,
|
context: AppContext,
|
||||||
authContext: AuthContext,
|
authContext: AuthContext,
|
||||||
configuration: Configuration,
|
configuration: Configuration
|
||||||
followedUsers: AnyPublisher<[String], Never>,
|
|
||||||
blockedUsers: AnyPublisher<[String], Never>
|
|
||||||
) -> UITableViewDiffableDataSource<UserSection, UserItem> {
|
) -> UITableViewDiffableDataSource<UserSection, UserItem> {
|
||||||
tableView.register(UserTableViewCell.self, forCellReuseIdentifier: String(describing: UserTableViewCell.self))
|
tableView.register(UserTableViewCell.self, forCellReuseIdentifier: String(describing: UserTableViewCell.self))
|
||||||
tableView.register(TimelineBottomLoaderTableViewCell.self, forCellReuseIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self))
|
tableView.register(TimelineBottomLoaderTableViewCell.self, forCellReuseIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self))
|
||||||
|
@ -50,7 +48,7 @@ extension UserSection {
|
||||||
authContext: authContext,
|
authContext: authContext,
|
||||||
tableView: tableView,
|
tableView: tableView,
|
||||||
cell: cell,
|
cell: cell,
|
||||||
viewModel: .init(value: .user(user), followedUsers: followedUsers, blockedUsers: blockedUsers),
|
viewModel: .init(value: .user(user), followedUsers: authContext.mastodonAuthenticationBox.inMemoryCache.$followingUserIds.eraseToAnyPublisher(), blockedUsers: authContext.mastodonAuthenticationBox.inMemoryCache.$blockedUserIds.eraseToAnyPublisher()),
|
||||||
configuration: configuration
|
configuration: configuration
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,32 +10,45 @@ extension DataSourceFacade {
|
||||||
static func responseToUserViewButtonAction(
|
static func responseToUserViewButtonAction(
|
||||||
dependency: NeedsDependency & AuthContextProvider,
|
dependency: NeedsDependency & AuthContextProvider,
|
||||||
user: ManagedObjectRecord<MastodonUser>,
|
user: ManagedObjectRecord<MastodonUser>,
|
||||||
buttonState: UserView.ButtonState,
|
buttonState: UserView.ButtonState
|
||||||
viewModel: FollowedBlockedUserIdProviding
|
|
||||||
) async throws {
|
) async throws {
|
||||||
switch buttonState {
|
switch buttonState {
|
||||||
case .follow, .unfollow:
|
case .follow:
|
||||||
try await DataSourceFacade.responseToUserFollowAction(
|
try await DataSourceFacade.responseToUserFollowAction(
|
||||||
dependency: dependency,
|
dependency: dependency,
|
||||||
user: user
|
user: user
|
||||||
)
|
)
|
||||||
fetchFollowedBlockedUserIds(in: viewModel)
|
// fetchFollowedBlockedUserIds(in: viewModel)
|
||||||
|
if let userObject = user.object(in: dependency.context.managedObjectContext) {
|
||||||
|
dependency.authContext.mastodonAuthenticationBox.inMemoryCache.followingUserIds.append(userObject.id)
|
||||||
|
}
|
||||||
|
case .unfollow:
|
||||||
|
try await DataSourceFacade.responseToUserFollowAction(
|
||||||
|
dependency: dependency,
|
||||||
|
user: user
|
||||||
|
)
|
||||||
|
if let userObject = user.object(in: dependency.context.managedObjectContext) {
|
||||||
|
dependency.authContext.mastodonAuthenticationBox.inMemoryCache.followingUserIds.removeAll(where: { $0 == userObject.id })
|
||||||
|
}
|
||||||
case .blocked:
|
case .blocked:
|
||||||
try await DataSourceFacade.responseToUserBlockAction(
|
try await DataSourceFacade.responseToUserBlockAction(
|
||||||
dependency: dependency,
|
dependency: dependency,
|
||||||
user: user
|
user: user
|
||||||
)
|
)
|
||||||
fetchFollowedBlockedUserIds(in: viewModel)
|
// fetchFollowedBlockedUserIds(in: viewModel)
|
||||||
|
if let userObject = user.object(in: dependency.context.managedObjectContext) {
|
||||||
|
dependency.authContext.mastodonAuthenticationBox.inMemoryCache.blockedUserIds.append(userObject.id)
|
||||||
|
}
|
||||||
case .none, .loading:
|
case .none, .loading:
|
||||||
break //no-op
|
break //no-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func fetchFollowedBlockedUserIds(in viewModel: FollowedBlockedUserIdProviding) {
|
// private static func fetchFollowedBlockedUserIds(in viewModel: FollowedBlockedUserIdProviding) {
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { // hack: otherwise fetching the blocked users will not return the user followed
|
// DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { // hack: otherwise fetching the blocked users will not return the user followed
|
||||||
Task { @MainActor in
|
// Task { @MainActor in
|
||||||
try await viewModel.fetchFollowedBlockedUserIds()
|
// try await viewModel.fetchFollowedBlockedUserIds()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,8 +99,7 @@ extension FamiliarFollowersViewController: UserTableViewCellDelegate {
|
||||||
try await DataSourceFacade.responseToUserViewButtonAction(
|
try await DataSourceFacade.responseToUserViewButtonAction(
|
||||||
dependency: self,
|
dependency: self,
|
||||||
user: user.asRecord,
|
user: user.asRecord,
|
||||||
buttonState: state,
|
buttonState: state
|
||||||
viewModel: viewModel
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,7 @@ extension FamiliarFollowersViewModel {
|
||||||
authContext: authContext,
|
authContext: authContext,
|
||||||
configuration: UserSection.Configuration(
|
configuration: UserSection.Configuration(
|
||||||
userTableViewCellDelegate: userTableViewCellDelegate
|
userTableViewCellDelegate: userTableViewCellDelegate
|
||||||
),
|
)
|
||||||
followedUsers: followedUserIds.eraseToAnyPublisher(),
|
|
||||||
blockedUsers: blockedUserIds.eraseToAnyPublisher()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
userFetchedResultsController.$records
|
userFetchedResultsController.$records
|
||||||
|
|
|
@ -11,7 +11,7 @@ import MastodonCore
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
|
|
||||||
final class FamiliarFollowersViewModel: FollowedBlockedUserIdProviding {
|
final class FamiliarFollowersViewModel {
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
|
||||||
// input
|
// input
|
||||||
|
@ -23,10 +23,7 @@ final class FamiliarFollowersViewModel: FollowedBlockedUserIdProviding {
|
||||||
|
|
||||||
// output
|
// output
|
||||||
var diffableDataSource: UITableViewDiffableDataSource<UserSection, UserItem>?
|
var diffableDataSource: UITableViewDiffableDataSource<UserSection, UserItem>?
|
||||||
|
|
||||||
var followedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
var blockedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
|
|
||||||
init(context: AppContext, authContext: AuthContext) {
|
init(context: AppContext, authContext: AuthContext) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.authContext = authContext
|
self.authContext = authContext
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
// Copyright © 2023 Mastodon gGmbH. All rights reserved.
|
|
||||||
|
|
||||||
import Combine
|
|
||||||
import MastodonCore
|
|
||||||
|
|
||||||
protocol FollowedBlockedUserIdProviding {
|
|
||||||
var context: AppContext { get }
|
|
||||||
var authContext: AuthContext { get }
|
|
||||||
|
|
||||||
var followedUserIds: CurrentValueSubject<[String], Never> { get }
|
|
||||||
var blockedUserIds: CurrentValueSubject<[String], Never> { get }
|
|
||||||
}
|
|
||||||
|
|
||||||
extension FollowedBlockedUserIdProviding {
|
|
||||||
func fetchFollowedBlockedUserIds() async throws {
|
|
||||||
let followingIds = try await context.apiService.following(
|
|
||||||
userID: authContext.mastodonAuthenticationBox.userID,
|
|
||||||
maxID: nil,
|
|
||||||
authenticationBox: authContext.mastodonAuthenticationBox
|
|
||||||
).value.map { $0.id }
|
|
||||||
|
|
||||||
let blockedIds = try await context.apiService.getBlocked(
|
|
||||||
authenticationBox: authContext.mastodonAuthenticationBox
|
|
||||||
).value.map { $0.id }
|
|
||||||
|
|
||||||
Task { @MainActor in
|
|
||||||
followedUserIds.send(followingIds)
|
|
||||||
blockedUserIds.send(blockedIds)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -125,8 +125,7 @@ extension FollowerListViewController: UserTableViewCellDelegate {
|
||||||
try await DataSourceFacade.responseToUserViewButtonAction(
|
try await DataSourceFacade.responseToUserViewButtonAction(
|
||||||
dependency: self,
|
dependency: self,
|
||||||
user: user.asRecord,
|
user: user.asRecord,
|
||||||
buttonState: state,
|
buttonState: state
|
||||||
viewModel: viewModel
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,7 @@ extension FollowerListViewModel {
|
||||||
authContext: authContext,
|
authContext: authContext,
|
||||||
configuration: UserSection.Configuration(
|
configuration: UserSection.Configuration(
|
||||||
userTableViewCellDelegate: userTableViewCellDelegate
|
userTableViewCellDelegate: userTableViewCellDelegate
|
||||||
),
|
)
|
||||||
followedUsers: followedUserIds.eraseToAnyPublisher(),
|
|
||||||
blockedUsers: blockedUserIds.eraseToAnyPublisher()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// workaround to append loader wrong animation issue
|
// workaround to append loader wrong animation issue
|
||||||
|
|
|
@ -155,8 +155,6 @@ extension FollowerListViewModel.State {
|
||||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||||
)
|
)
|
||||||
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch \(response.value.count) followers")
|
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch \(response.value.count) followers")
|
||||||
|
|
||||||
try await viewModel.fetchFollowedBlockedUserIds()
|
|
||||||
|
|
||||||
var hasNewAppend = false
|
var hasNewAppend = false
|
||||||
var userIDs = viewModel.userFetchedResultsController.userIDs
|
var userIDs = viewModel.userFetchedResultsController.userIDs
|
||||||
|
|
|
@ -13,7 +13,7 @@ import GameplayKit
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
|
|
||||||
final class FollowerListViewModel: FollowedBlockedUserIdProviding {
|
final class FollowerListViewModel {
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
|
||||||
// input
|
// input
|
||||||
|
@ -24,9 +24,6 @@ final class FollowerListViewModel: FollowedBlockedUserIdProviding {
|
||||||
|
|
||||||
@Published var domain: String?
|
@Published var domain: String?
|
||||||
@Published var userID: String?
|
@Published var userID: String?
|
||||||
|
|
||||||
var followedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
var blockedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
|
|
||||||
// output
|
// output
|
||||||
var diffableDataSource: UITableViewDiffableDataSource<UserSection, UserItem>?
|
var diffableDataSource: UITableViewDiffableDataSource<UserSection, UserItem>?
|
||||||
|
|
|
@ -123,8 +123,7 @@ extension FollowingListViewController: UserTableViewCellDelegate {
|
||||||
try await DataSourceFacade.responseToUserViewButtonAction(
|
try await DataSourceFacade.responseToUserViewButtonAction(
|
||||||
dependency: self,
|
dependency: self,
|
||||||
user: user.asRecord,
|
user: user.asRecord,
|
||||||
buttonState: state,
|
buttonState: state
|
||||||
viewModel: viewModel
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,7 @@ extension FollowingListViewModel {
|
||||||
authContext: authContext,
|
authContext: authContext,
|
||||||
configuration: UserSection.Configuration(
|
configuration: UserSection.Configuration(
|
||||||
userTableViewCellDelegate: userTableViewCellDelegate
|
userTableViewCellDelegate: userTableViewCellDelegate
|
||||||
),
|
)
|
||||||
followedUsers: authContext.mastodonAuthenticationBox.inMemoryCache.$followingUserIds.eraseToAnyPublisher(),
|
|
||||||
blockedUsers: authContext.mastodonAuthenticationBox.inMemoryCache.$blockedUserIds.eraseToAnyPublisher()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// workaround to append loader wrong animation issue
|
// workaround to append loader wrong animation issue
|
||||||
|
|
|
@ -158,8 +158,6 @@ extension FollowingListViewModel.State {
|
||||||
userIDs.append(user.id)
|
userIDs.append(user.id)
|
||||||
hasNewAppend = true
|
hasNewAppend = true
|
||||||
}
|
}
|
||||||
|
|
||||||
try await viewModel.fetchFollowedBlockedUserIds()
|
|
||||||
|
|
||||||
let maxID = response.link?.maxID
|
let maxID = response.link?.maxID
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import GameplayKit
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
final class FollowingListViewModel: FollowedBlockedUserIdProviding {
|
final class FollowingListViewModel {
|
||||||
|
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
|
||||||
|
@ -40,10 +40,7 @@ final class FollowingListViewModel: FollowedBlockedUserIdProviding {
|
||||||
stateMachine.enter(State.Initial.self)
|
stateMachine.enter(State.Initial.self)
|
||||||
return stateMachine
|
return stateMachine
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var followedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
var blockedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
|
|
||||||
init(
|
init(
|
||||||
context: AppContext,
|
context: AppContext,
|
||||||
authContext: AuthContext,
|
authContext: AuthContext,
|
||||||
|
|
|
@ -68,9 +68,7 @@ extension FavoritedByViewController {
|
||||||
tableView.delegate = self
|
tableView.delegate = self
|
||||||
viewModel.setupDiffableDataSource(
|
viewModel.setupDiffableDataSource(
|
||||||
tableView: tableView,
|
tableView: tableView,
|
||||||
userTableViewCellDelegate: self,
|
userTableViewCellDelegate: self
|
||||||
followedUsers: viewModel.followedUserIds.eraseToAnyPublisher(),
|
|
||||||
blockedUsers: viewModel.blockedUserIds.eraseToAnyPublisher()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// setup batch fetch
|
// setup batch fetch
|
||||||
|
@ -117,8 +115,7 @@ extension FavoritedByViewController: UserTableViewCellDelegate {
|
||||||
try await DataSourceFacade.responseToUserViewButtonAction(
|
try await DataSourceFacade.responseToUserViewButtonAction(
|
||||||
dependency: self,
|
dependency: self,
|
||||||
user: user.asRecord,
|
user: user.asRecord,
|
||||||
buttonState: state,
|
buttonState: state
|
||||||
viewModel: viewModel
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,9 +68,7 @@ extension RebloggedByViewController {
|
||||||
tableView.delegate = self
|
tableView.delegate = self
|
||||||
viewModel.setupDiffableDataSource(
|
viewModel.setupDiffableDataSource(
|
||||||
tableView: tableView,
|
tableView: tableView,
|
||||||
userTableViewCellDelegate: self,
|
userTableViewCellDelegate: self
|
||||||
followedUsers: viewModel.followedUserIds.eraseToAnyPublisher(),
|
|
||||||
blockedUsers: viewModel.blockedUserIds.eraseToAnyPublisher()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// setup batch fetch
|
// setup batch fetch
|
||||||
|
@ -117,8 +115,7 @@ extension RebloggedByViewController: UserTableViewCellDelegate {
|
||||||
try await DataSourceFacade.responseToUserViewButtonAction(
|
try await DataSourceFacade.responseToUserViewButtonAction(
|
||||||
dependency: self,
|
dependency: self,
|
||||||
user: user.asRecord,
|
user: user.asRecord,
|
||||||
buttonState: state,
|
buttonState: state
|
||||||
viewModel: viewModel
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,7 @@ extension UserListViewModel {
|
||||||
@MainActor
|
@MainActor
|
||||||
func setupDiffableDataSource(
|
func setupDiffableDataSource(
|
||||||
tableView: UITableView,
|
tableView: UITableView,
|
||||||
userTableViewCellDelegate: UserTableViewCellDelegate?,
|
userTableViewCellDelegate: UserTableViewCellDelegate?
|
||||||
followedUsers: AnyPublisher<[String], Never>,
|
|
||||||
blockedUsers: AnyPublisher<[String], Never>
|
|
||||||
) {
|
) {
|
||||||
diffableDataSource = UserSection.diffableDataSource(
|
diffableDataSource = UserSection.diffableDataSource(
|
||||||
tableView: tableView,
|
tableView: tableView,
|
||||||
|
@ -24,9 +22,7 @@ extension UserListViewModel {
|
||||||
authContext: authContext,
|
authContext: authContext,
|
||||||
configuration: UserSection.Configuration(
|
configuration: UserSection.Configuration(
|
||||||
userTableViewCellDelegate: userTableViewCellDelegate
|
userTableViewCellDelegate: userTableViewCellDelegate
|
||||||
),
|
)
|
||||||
followedUsers: followedUsers,
|
|
||||||
blockedUsers: blockedUsers
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// workaround to append loader wrong animation issue
|
// workaround to append loader wrong animation issue
|
||||||
|
|
|
@ -165,9 +165,7 @@ extension UserListViewModel.State {
|
||||||
userIDs.append(user.id)
|
userIDs.append(user.id)
|
||||||
hasNewAppend = true
|
hasNewAppend = true
|
||||||
}
|
}
|
||||||
|
|
||||||
try await viewModel.fetchFollowedBlockedUserIds()
|
|
||||||
|
|
||||||
let maxID = response.link?.maxID
|
let maxID = response.link?.maxID
|
||||||
|
|
||||||
if hasNewAppend, maxID != nil {
|
if hasNewAppend, maxID != nil {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import CoreDataStack
|
||||||
import GameplayKit
|
import GameplayKit
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
|
|
||||||
final class UserListViewModel: FollowedBlockedUserIdProviding {
|
final class UserListViewModel {
|
||||||
let logger = Logger(subsystem: "UserListViewModel", category: "ViewModel")
|
let logger = Logger(subsystem: "UserListViewModel", category: "ViewModel")
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
|
||||||
|
@ -36,10 +36,7 @@ final class UserListViewModel: FollowedBlockedUserIdProviding {
|
||||||
stateMachine.enter(State.Initial.self)
|
stateMachine.enter(State.Initial.self)
|
||||||
return stateMachine
|
return stateMachine
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var followedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
var blockedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
context: AppContext,
|
context: AppContext,
|
||||||
authContext: AuthContext,
|
authContext: AuthContext,
|
||||||
|
|
|
@ -55,12 +55,6 @@ extension SearchHistoryViewController {
|
||||||
collectionView: collectionView,
|
collectionView: collectionView,
|
||||||
searchHistorySectionHeaderCollectionReusableViewDelegate: self
|
searchHistorySectionHeaderCollectionReusableViewDelegate: self
|
||||||
)
|
)
|
||||||
|
|
||||||
Task {
|
|
||||||
do {
|
|
||||||
try await viewModel.fetchFollowedBlockedUserIds()
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,8 +130,7 @@ extension SearchHistoryViewController: SearchHistorySectionHeaderCollectionReusa
|
||||||
try await DataSourceFacade.responseToUserViewButtonAction(
|
try await DataSourceFacade.responseToUserViewButtonAction(
|
||||||
dependency: self,
|
dependency: self,
|
||||||
user: user.asRecord,
|
user: user.asRecord,
|
||||||
buttonState: state,
|
buttonState: state
|
||||||
viewModel: viewModel
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import CoreDataStack
|
||||||
import CommonOSLog
|
import CommonOSLog
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
|
|
||||||
final class SearchHistoryViewModel: FollowedBlockedUserIdProviding {
|
final class SearchHistoryViewModel {
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
|
||||||
// input
|
// input
|
||||||
|
@ -21,9 +21,7 @@ final class SearchHistoryViewModel: FollowedBlockedUserIdProviding {
|
||||||
|
|
||||||
// output
|
// output
|
||||||
var diffableDataSource: UICollectionViewDiffableDataSource<SearchHistorySection, SearchHistoryItem>?
|
var diffableDataSource: UICollectionViewDiffableDataSource<SearchHistorySection, SearchHistoryItem>?
|
||||||
var followedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
var blockedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
|
|
||||||
init(context: AppContext, authContext: AuthContext) {
|
init(context: AppContext, authContext: AuthContext) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.authContext = authContext
|
self.authContext = authContext
|
||||||
|
|
|
@ -265,8 +265,7 @@ extension SearchResultViewController: UserTableViewCellDelegate {
|
||||||
try await DataSourceFacade.responseToUserViewButtonAction(
|
try await DataSourceFacade.responseToUserViewButtonAction(
|
||||||
dependency: self,
|
dependency: self,
|
||||||
user: user.asRecord,
|
user: user.asRecord,
|
||||||
buttonState: state,
|
buttonState: state
|
||||||
viewModel: viewModel
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,7 @@ extension SearchResultViewModel {
|
||||||
authContext: authContext,
|
authContext: authContext,
|
||||||
statusViewTableViewCellDelegate: statusTableViewCellDelegate,
|
statusViewTableViewCellDelegate: statusTableViewCellDelegate,
|
||||||
userTableViewCellDelegate: userTableViewCellDelegate
|
userTableViewCellDelegate: userTableViewCellDelegate
|
||||||
),
|
)
|
||||||
followedUsers: followedUserIds.eraseToAnyPublisher(),
|
|
||||||
blockedUsers: blockedUserIds.eraseToAnyPublisher()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var snapshot = NSDiffableDataSourceSnapshot<SearchResultSection, SearchResultItem>()
|
var snapshot = NSDiffableDataSourceSnapshot<SearchResultSection, SearchResultItem>()
|
||||||
|
|
|
@ -14,7 +14,7 @@ import CommonOSLog
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
|
|
||||||
final class SearchResultViewModel: FollowedBlockedUserIdProviding {
|
final class SearchResultViewModel {
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
|
||||||
// input
|
// input
|
||||||
|
@ -48,9 +48,6 @@ final class SearchResultViewModel: FollowedBlockedUserIdProviding {
|
||||||
}()
|
}()
|
||||||
let didDataSourceUpdate = PassthroughSubject<Void, Never>()
|
let didDataSourceUpdate = PassthroughSubject<Void, Never>()
|
||||||
|
|
||||||
var followedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
var blockedUserIds = CurrentValueSubject<[String], Never>([])
|
|
||||||
|
|
||||||
init(context: AppContext, authContext: AuthContext, searchScope: SearchDetailViewModel.SearchScope) {
|
init(context: AppContext, authContext: AuthContext, searchScope: SearchDetailViewModel.SearchScope) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.authContext = authContext
|
self.authContext = authContext
|
||||||
|
|
Loading…
Reference in New Issue