Rename classes
This commit is contained in:
parent
0045e7d9a4
commit
7af1bea2ce
|
@ -29,12 +29,12 @@ extension DiscoveryCommunityViewController: DataSourceProvider {
|
|||
}
|
||||
|
||||
func update(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.update(status: status)
|
||||
viewModel.dataController.update(status: status)
|
||||
}
|
||||
|
||||
func delete(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.setRecords(
|
||||
viewModel.statusFetchedResultsController.records.filter { $0.id != status.id }
|
||||
viewModel.dataController.setRecords(
|
||||
viewModel.dataController.records.filter { $0.id != status.id }
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ extension DiscoveryCommunityViewModel {
|
|||
|
||||
stateMachine.enter(State.Reloading.self)
|
||||
|
||||
statusFetchedResultsController.$records
|
||||
dataController.$records
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] records in
|
||||
guard let self = self else { return }
|
||||
|
|
|
@ -145,7 +145,7 @@ extension DiscoveryCommunityViewModel.State {
|
|||
self.maxID = newMaxID
|
||||
|
||||
var hasNewStatusesAppend = false
|
||||
var statusIDs = isReloading ? [] : await viewModel.statusFetchedResultsController.records
|
||||
var statusIDs = isReloading ? [] : await viewModel.dataController.records
|
||||
for status in response.value {
|
||||
guard !statusIDs.contains(where: { $0.id == status.id }) else { continue }
|
||||
statusIDs.append(.fromEntity(status))
|
||||
|
@ -158,7 +158,7 @@ extension DiscoveryCommunityViewModel.State {
|
|||
} else {
|
||||
await enter(state: NoMore.self)
|
||||
}
|
||||
await viewModel.statusFetchedResultsController.setRecords(statusIDs)
|
||||
await viewModel.dataController.setRecords(statusIDs)
|
||||
viewModel.didLoadLatest.send()
|
||||
|
||||
} catch {
|
||||
|
|
|
@ -21,7 +21,7 @@ final class DiscoveryCommunityViewModel {
|
|||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let viewDidAppeared = PassthroughSubject<Void, Never>()
|
||||
let statusFetchedResultsController: StatusFetchedResultsController
|
||||
let dataController: StatusDataController
|
||||
let listBatchFetchViewModel = ListBatchFetchViewModel()
|
||||
|
||||
// output
|
||||
|
@ -45,7 +45,7 @@ final class DiscoveryCommunityViewModel {
|
|||
init(context: AppContext, authContext: AuthContext) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.statusFetchedResultsController = StatusFetchedResultsController()
|
||||
self.dataController = StatusDataController()
|
||||
// end init
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,12 +29,12 @@ extension DiscoveryPostsViewController: DataSourceProvider {
|
|||
}
|
||||
|
||||
func update(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.update(status: status)
|
||||
viewModel.dataController.update(status: status)
|
||||
}
|
||||
|
||||
func delete(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.setRecords(
|
||||
viewModel.statusFetchedResultsController.records.filter { $0.id != status.id }
|
||||
viewModel.dataController.setRecords(
|
||||
viewModel.dataController.records.filter { $0.id != status.id }
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ extension DiscoveryPostsViewModel {
|
|||
|
||||
stateMachine.enter(State.Reloading.self)
|
||||
|
||||
statusFetchedResultsController.$records
|
||||
dataController.$records
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] records in
|
||||
guard let self = self else { return }
|
||||
|
|
|
@ -143,7 +143,7 @@ extension DiscoveryPostsViewModel.State {
|
|||
self.offset = newOffset
|
||||
|
||||
var hasNewStatusesAppend = false
|
||||
var statusIDs = isReloading ? [] : await viewModel.statusFetchedResultsController.records
|
||||
var statusIDs = isReloading ? [] : await viewModel.dataController.records
|
||||
for status in response.value {
|
||||
guard !statusIDs.contains(where: { $0.id == status.id }) else { continue }
|
||||
statusIDs.append(.fromEntity(status))
|
||||
|
@ -155,7 +155,7 @@ extension DiscoveryPostsViewModel.State {
|
|||
} else {
|
||||
await enter(state: NoMore.self)
|
||||
}
|
||||
await viewModel.statusFetchedResultsController.setRecords(statusIDs)
|
||||
await viewModel.dataController.setRecords(statusIDs)
|
||||
viewModel.didLoadLatest.send()
|
||||
|
||||
} catch {
|
||||
|
|
|
@ -20,7 +20,7 @@ final class DiscoveryPostsViewModel {
|
|||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let statusFetchedResultsController: StatusFetchedResultsController
|
||||
let dataController: StatusDataController
|
||||
let listBatchFetchViewModel = ListBatchFetchViewModel()
|
||||
|
||||
// output
|
||||
|
@ -45,7 +45,7 @@ final class DiscoveryPostsViewModel {
|
|||
init(context: AppContext, authContext: AuthContext) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.statusFetchedResultsController = StatusFetchedResultsController()
|
||||
self.dataController = StatusDataController()
|
||||
// end init
|
||||
|
||||
Task {
|
||||
|
|
|
@ -24,7 +24,7 @@ final class HashtagTimelineViewModel {
|
|||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let fetchedResultsController: StatusFetchedResultsController
|
||||
let fetchedResultsController: StatusDataController
|
||||
let isFetchingLatestTimeline = CurrentValueSubject<Bool, Never>(false)
|
||||
let timelinePredicate = CurrentValueSubject<NSPredicate?, Never>(nil)
|
||||
let hashtagEntity = CurrentValueSubject<Mastodon.Entity.Tag?, Never>(nil)
|
||||
|
@ -55,7 +55,7 @@ final class HashtagTimelineViewModel {
|
|||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.hashtag = hashtag
|
||||
self.fetchedResultsController = StatusFetchedResultsController()
|
||||
self.fetchedResultsController = StatusDataController()
|
||||
updateTagInformation()
|
||||
// end init
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ final class HomeTimelineViewModel: NSObject {
|
|||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let fetchedResultsController: FeedFetchedResultsController
|
||||
let fetchedResultsController: FeedDataController
|
||||
let homeTimelineNavigationBarTitleViewModel: HomeTimelineNavigationBarTitleViewModel
|
||||
let listBatchFetchViewModel = ListBatchFetchViewModel()
|
||||
|
||||
|
@ -81,7 +81,7 @@ final class HomeTimelineViewModel: NSObject {
|
|||
init(context: AppContext, authContext: AuthContext) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.fetchedResultsController = FeedFetchedResultsController(context: context, authContext: authContext)
|
||||
self.fetchedResultsController = FeedDataController(context: context, authContext: authContext)
|
||||
self.homeTimelineNavigationBarTitleViewModel = HomeTimelineNavigationBarTitleViewModel(context: context)
|
||||
super.init()
|
||||
self.fetchedResultsController.records = (try? FileManager.default.cachedHomeTimeline(for: authContext.mastodonAuthenticationBox).map {
|
||||
|
|
|
@ -38,11 +38,11 @@ extension NotificationTimelineViewController: DataSourceProvider {
|
|||
}
|
||||
|
||||
func update(status: MastodonStatus) {
|
||||
viewModel.feedFetchedResultsController.update(status: status)
|
||||
viewModel.dataController.update(status: status)
|
||||
}
|
||||
|
||||
func delete(status: MastodonStatus) {
|
||||
viewModel.feedFetchedResultsController.delete(status: status)
|
||||
viewModel.dataController.delete(status: status)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
|
|
@ -30,7 +30,7 @@ extension NotificationTimelineViewModel {
|
|||
snapshot.appendSections([.main])
|
||||
diffableDataSource?.apply(snapshot)
|
||||
|
||||
feedFetchedResultsController.$records
|
||||
dataController.$records
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] records in
|
||||
guard let self = self else { return }
|
||||
|
|
|
@ -32,7 +32,7 @@ extension NotificationTimelineViewModel.LoadOldestState {
|
|||
class Initial: NotificationTimelineViewModel.LoadOldestState {
|
||||
override func isValidNextState(_ stateClass: AnyClass) -> Bool {
|
||||
guard let viewModel = viewModel else { return false }
|
||||
guard !viewModel.feedFetchedResultsController.records.isEmpty else { return false }
|
||||
guard !viewModel.dataController.records.isEmpty else { return false }
|
||||
return stateClass == Loading.self
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ extension NotificationTimelineViewModel.LoadOldestState {
|
|||
|
||||
guard let viewModel = viewModel, let stateMachine = stateMachine else { return }
|
||||
|
||||
guard let lastFeedRecord = viewModel.feedFetchedResultsController.records.last else {
|
||||
guard let lastFeedRecord = viewModel.dataController.records.last else {
|
||||
stateMachine.enter(Fail.self)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ final class NotificationTimelineViewModel {
|
|||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let scope: Scope
|
||||
let feedFetchedResultsController: FeedFetchedResultsController
|
||||
let dataController: FeedDataController
|
||||
let listBatchFetchViewModel = ListBatchFetchViewModel()
|
||||
@Published var isLoadingLatest = false
|
||||
@Published var lastAutomaticFetchTimestamp: Date?
|
||||
|
@ -52,20 +52,20 @@ final class NotificationTimelineViewModel {
|
|||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.scope = scope
|
||||
self.feedFetchedResultsController = FeedFetchedResultsController(context: context, authContext: authContext)
|
||||
self.dataController = FeedDataController(context: context, authContext: authContext)
|
||||
|
||||
switch scope {
|
||||
case .everything:
|
||||
self.feedFetchedResultsController.records = (try? FileManager.default.cachedNotificationsAll(for: authContext.mastodonAuthenticationBox))?.map({ notification in
|
||||
self.dataController.records = (try? FileManager.default.cachedNotificationsAll(for: authContext.mastodonAuthenticationBox))?.map({ notification in
|
||||
MastodonFeed.fromNotification(notification, kind: .notificationAll)
|
||||
}) ?? []
|
||||
case .mentions:
|
||||
self.feedFetchedResultsController.records = (try? FileManager.default.cachedNotificationsMentions(for: authContext.mastodonAuthenticationBox))?.map({ notification in
|
||||
self.dataController.records = (try? FileManager.default.cachedNotificationsMentions(for: authContext.mastodonAuthenticationBox))?.map({ notification in
|
||||
MastodonFeed.fromNotification(notification, kind: .notificationMentions)
|
||||
}) ?? []
|
||||
}
|
||||
|
||||
self.feedFetchedResultsController.$records
|
||||
self.dataController.$records
|
||||
.removeDuplicates()
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink(receiveValue: { feeds in
|
||||
|
@ -101,9 +101,9 @@ extension NotificationTimelineViewModel {
|
|||
|
||||
switch scope {
|
||||
case .everything:
|
||||
feedFetchedResultsController.loadInitial(kind: .notificationAll)
|
||||
dataController.loadInitial(kind: .notificationAll)
|
||||
case .mentions:
|
||||
feedFetchedResultsController.loadInitial(kind: .notificationMentions)
|
||||
dataController.loadInitial(kind: .notificationMentions)
|
||||
}
|
||||
|
||||
didLoadLatest.send()
|
||||
|
@ -113,9 +113,9 @@ extension NotificationTimelineViewModel {
|
|||
func loadMore(item: NotificationItem) async {
|
||||
switch scope {
|
||||
case .everything:
|
||||
feedFetchedResultsController.loadNext(kind: .notificationAll)
|
||||
dataController.loadNext(kind: .notificationAll)
|
||||
case .mentions:
|
||||
feedFetchedResultsController.loadNext(kind: .notificationMentions)
|
||||
dataController.loadNext(kind: .notificationMentions)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,12 +29,12 @@ extension BookmarkViewController: DataSourceProvider {
|
|||
}
|
||||
|
||||
func update(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.update(status: status)
|
||||
viewModel.dataController.update(status: status)
|
||||
}
|
||||
|
||||
func delete(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.setRecords(
|
||||
viewModel.statusFetchedResultsController.records.filter { $0.id != status.id }
|
||||
viewModel.dataController.setRecords(
|
||||
viewModel.dataController.records.filter { $0.id != status.id }
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ extension BookmarkViewModel {
|
|||
|
||||
stateMachine.enter(State.Reloading.self)
|
||||
|
||||
statusFetchedResultsController.$records
|
||||
dataController.$records
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] records in
|
||||
guard let self = self else { return }
|
||||
|
|
|
@ -58,7 +58,7 @@ extension BookmarkViewModel.State {
|
|||
|
||||
// reset
|
||||
DispatchQueue.main.async {
|
||||
viewModel.statusFetchedResultsController.reset()
|
||||
viewModel.dataController.reset()
|
||||
}
|
||||
|
||||
stateMachine.enter(Loading.self)
|
||||
|
@ -130,7 +130,7 @@ extension BookmarkViewModel.State {
|
|||
)
|
||||
|
||||
var hasNewStatusesAppend = false
|
||||
var statusIDs = await viewModel.statusFetchedResultsController.records.map { $0.entity }
|
||||
var statusIDs = await viewModel.dataController.records.map { $0.entity }
|
||||
for status in response.value {
|
||||
guard !statusIDs.contains(status) else { continue }
|
||||
statusIDs.append(status)
|
||||
|
@ -150,7 +150,7 @@ extension BookmarkViewModel.State {
|
|||
await enter(state: NoMore.self)
|
||||
}
|
||||
|
||||
await viewModel.statusFetchedResultsController.setRecords(statusIDs.map { MastodonStatus.fromEntity($0) })
|
||||
await viewModel.dataController.setRecords(statusIDs.map { MastodonStatus.fromEntity($0) })
|
||||
|
||||
} catch {
|
||||
await enter(state: Fail.self)
|
||||
|
|
|
@ -20,7 +20,7 @@ final class BookmarkViewModel {
|
|||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
|
||||
let statusFetchedResultsController: StatusFetchedResultsController
|
||||
let dataController: StatusDataController
|
||||
let listBatchFetchViewModel = ListBatchFetchViewModel()
|
||||
|
||||
// output
|
||||
|
@ -42,7 +42,7 @@ final class BookmarkViewModel {
|
|||
init(context: AppContext, authContext: AuthContext) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.statusFetchedResultsController = StatusFetchedResultsController()
|
||||
self.dataController = StatusDataController()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,12 +29,12 @@ extension FavoriteViewController: DataSourceProvider {
|
|||
}
|
||||
|
||||
func update(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.update(status: status)
|
||||
viewModel.dataController.update(status: status)
|
||||
}
|
||||
|
||||
func delete(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.setRecords(
|
||||
viewModel.statusFetchedResultsController.records.filter { $0.id != status.id }
|
||||
viewModel.dataController.setRecords(
|
||||
viewModel.dataController.records.filter { $0.id != status.id }
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ extension FavoriteViewModel {
|
|||
|
||||
stateMachine.enter(State.Reloading.self)
|
||||
|
||||
statusFetchedResultsController.$records
|
||||
dataController.$records
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] records in
|
||||
guard let self = self else { return }
|
||||
|
|
|
@ -57,7 +57,7 @@ extension FavoriteViewModel.State {
|
|||
|
||||
Task {
|
||||
// reset
|
||||
await viewModel.statusFetchedResultsController.reset()
|
||||
await viewModel.dataController.reset()
|
||||
|
||||
stateMachine.enter(Loading.self)
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ extension FavoriteViewModel.State {
|
|||
)
|
||||
|
||||
var hasNewStatusesAppend = false
|
||||
var statusIDs = await viewModel.statusFetchedResultsController.records
|
||||
var statusIDs = await viewModel.dataController.records
|
||||
for status in response.value {
|
||||
guard !statusIDs.contains(where: { $0.id == status.id }) else { continue }
|
||||
statusIDs.append(.fromEntity(status))
|
||||
|
@ -148,7 +148,7 @@ extension FavoriteViewModel.State {
|
|||
} else {
|
||||
await enter(state: NoMore.self)
|
||||
}
|
||||
await viewModel.statusFetchedResultsController.setRecords(statusIDs)
|
||||
await viewModel.dataController.setRecords(statusIDs)
|
||||
} catch {
|
||||
await enter(state: Fail.self)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ final class FavoriteViewModel {
|
|||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let statusFetchedResultsController: StatusFetchedResultsController
|
||||
let dataController: StatusDataController
|
||||
let listBatchFetchViewModel = ListBatchFetchViewModel()
|
||||
|
||||
// output
|
||||
|
@ -41,7 +41,7 @@ final class FavoriteViewModel {
|
|||
init(context: AppContext, authContext: AuthContext) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.statusFetchedResultsController = StatusFetchedResultsController()
|
||||
self.dataController = StatusDataController()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ extension UserTimelineViewController: DataSourceProvider {
|
|||
}
|
||||
|
||||
func update(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.update(status: status)
|
||||
viewModel.dataController.update(status: status)
|
||||
}
|
||||
|
||||
func delete(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.deleteRecord(status)
|
||||
viewModel.dataController.deleteRecord(status)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
|
|
@ -48,7 +48,7 @@ extension UserTimelineViewModel {
|
|||
).map { $0 || $1 || $2 }
|
||||
|
||||
Publishers.CombineLatest(
|
||||
statusFetchedResultsController.$records,
|
||||
dataController.$records,
|
||||
needsTimelineHidden.removeDuplicates()
|
||||
)
|
||||
.debounce(for: .milliseconds(300), scheduler: DispatchQueue.main)
|
||||
|
|
|
@ -57,7 +57,7 @@ extension UserTimelineViewModel.State {
|
|||
|
||||
Task {
|
||||
// reset
|
||||
await viewModel.statusFetchedResultsController.reset()
|
||||
await viewModel.dataController.reset()
|
||||
|
||||
stateMachine.enter(Loading.self)
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ extension UserTimelineViewModel.State {
|
|||
|
||||
|
||||
Task {
|
||||
let maxID = await viewModel.statusFetchedResultsController.records.last?.id
|
||||
let maxID = await viewModel.dataController.records.last?.id
|
||||
|
||||
guard let userID = viewModel.userIdentifier?.userID, !userID.isEmpty else {
|
||||
stateMachine.enter(Fail.self)
|
||||
|
@ -137,7 +137,7 @@ extension UserTimelineViewModel.State {
|
|||
)
|
||||
|
||||
var hasNewStatusesAppend = false
|
||||
var statusIDs = await viewModel.statusFetchedResultsController.records
|
||||
var statusIDs = await viewModel.dataController.records
|
||||
for status in response.value {
|
||||
guard !statusIDs.contains(where: { $0.id == status.id }) else { continue }
|
||||
statusIDs.append(.fromEntity(status))
|
||||
|
@ -149,7 +149,7 @@ extension UserTimelineViewModel.State {
|
|||
} else {
|
||||
await enter(state: NoMore.self)
|
||||
}
|
||||
await viewModel.statusFetchedResultsController.setRecords(statusIDs)
|
||||
await viewModel.dataController.setRecords(statusIDs)
|
||||
|
||||
} catch {
|
||||
await enter(state: Fail.self)
|
||||
|
|
|
@ -21,7 +21,7 @@ final class UserTimelineViewModel {
|
|||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let title: String
|
||||
let statusFetchedResultsController: StatusFetchedResultsController
|
||||
let dataController: StatusDataController
|
||||
let listBatchFetchViewModel = ListBatchFetchViewModel()
|
||||
@Published var userIdentifier: UserIdentifier?
|
||||
@Published var queryFilter: QueryFilter
|
||||
|
@ -58,7 +58,7 @@ final class UserTimelineViewModel {
|
|||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.title = title
|
||||
self.statusFetchedResultsController = StatusFetchedResultsController()
|
||||
self.dataController = StatusDataController()
|
||||
self.queryFilter = queryFilter
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ extension ReportStatusViewModel {
|
|||
snapshot.appendSections([.main])
|
||||
diffableDataSource?.apply(snapshot)
|
||||
|
||||
statusFetchedResultsController.$records
|
||||
dataController.$records
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] records in
|
||||
guard let self = self else { return }
|
||||
|
|
|
@ -66,7 +66,7 @@ extension ReportStatusViewModel.State {
|
|||
|
||||
|
||||
Task {
|
||||
let maxID = await viewModel.statusFetchedResultsController.records.last?.id
|
||||
let maxID = await viewModel.dataController.records.last?.id
|
||||
|
||||
let managedObjectContext = viewModel.context.managedObjectContext
|
||||
let _userID: MastodonUser.ID? = try await managedObjectContext.perform {
|
||||
|
@ -90,7 +90,7 @@ extension ReportStatusViewModel.State {
|
|||
)
|
||||
|
||||
var hasNewStatusesAppend = false
|
||||
var statusIDs = await viewModel.statusFetchedResultsController.records
|
||||
var statusIDs = await viewModel.dataController.records
|
||||
for status in response.value {
|
||||
guard !statusIDs.contains(where: { $0.id == status.id }) else { continue }
|
||||
statusIDs.append(.fromEntity(status))
|
||||
|
@ -102,7 +102,7 @@ extension ReportStatusViewModel.State {
|
|||
} else {
|
||||
await enter(state: NoMore.self)
|
||||
}
|
||||
await viewModel.statusFetchedResultsController.setRecords(statusIDs)
|
||||
await viewModel.dataController.setRecords(statusIDs)
|
||||
|
||||
} catch {
|
||||
await enter(state: Fail.self)
|
||||
|
|
|
@ -26,7 +26,7 @@ class ReportStatusViewModel {
|
|||
let authContext: AuthContext
|
||||
let user: ManagedObjectRecord<MastodonUser>
|
||||
let status: MastodonStatus?
|
||||
let statusFetchedResultsController: StatusFetchedResultsController
|
||||
let dataController: StatusDataController
|
||||
let listBatchFetchViewModel = ListBatchFetchViewModel()
|
||||
|
||||
@Published var isSkip = false
|
||||
|
@ -59,7 +59,7 @@ class ReportStatusViewModel {
|
|||
self.authContext = authContext
|
||||
self.user = user
|
||||
self.status = status
|
||||
self.statusFetchedResultsController = StatusFetchedResultsController()
|
||||
self.dataController = StatusDataController()
|
||||
// end init
|
||||
|
||||
if let status = status {
|
||||
|
|
|
@ -34,11 +34,11 @@ extension SearchResultViewController: DataSourceProvider {
|
|||
}
|
||||
|
||||
func update(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.update(status: status)
|
||||
viewModel.dataController.update(status: status)
|
||||
}
|
||||
|
||||
func delete(status: MastodonStatus) {
|
||||
viewModel.statusFetchedResultsController.deleteRecord(status)
|
||||
viewModel.dataController.deleteRecord(status)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
|
|
@ -33,7 +33,7 @@ extension SearchResultViewModel {
|
|||
diffableDataSource.apply(snapshot, animatingDifferences: false)
|
||||
|
||||
Publishers.CombineLatest3(
|
||||
statusFetchedResultsController.$records,
|
||||
dataController.$records,
|
||||
$accounts,
|
||||
$hashtags
|
||||
)
|
||||
|
|
|
@ -147,13 +147,13 @@ extension SearchResultViewModel.State {
|
|||
|
||||
// reset data source when the search is refresh
|
||||
if offset == nil {
|
||||
await viewModel.statusFetchedResultsController.reset()
|
||||
await viewModel.dataController.reset()
|
||||
viewModel.relationships = []
|
||||
viewModel.accounts = []
|
||||
viewModel.hashtags = []
|
||||
}
|
||||
|
||||
await viewModel.statusFetchedResultsController.appendRecords(statuses)
|
||||
await viewModel.dataController.appendRecords(statuses)
|
||||
|
||||
|
||||
var existingRelationships = viewModel.relationships
|
||||
|
|
|
@ -24,7 +24,7 @@ final class SearchResultViewModel {
|
|||
@Published var hashtags: [Mastodon.Entity.Tag] = []
|
||||
@Published var accounts: [Mastodon.Entity.Account] = []
|
||||
var relationships: [Mastodon.Entity.Relationship] = []
|
||||
let statusFetchedResultsController: StatusFetchedResultsController
|
||||
let dataController: StatusDataController
|
||||
let listBatchFetchViewModel = ListBatchFetchViewModel()
|
||||
|
||||
var cellFrameCache = NSCache<NSNumber, NSValue>()
|
||||
|
@ -55,6 +55,6 @@ final class SearchResultViewModel {
|
|||
self.accounts = []
|
||||
self.relationships = []
|
||||
|
||||
self.statusFetchedResultsController = StatusFetchedResultsController()
|
||||
self.dataController = StatusDataController()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
//
|
||||
// FeedFetchedResultsController.swift
|
||||
// FeedFetchedResultsController
|
||||
//
|
||||
// Created by Cirno MainasuK on 2021-8-19.
|
||||
// Copyright © 2021 Twidere. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Combine
|
||||
import MastodonSDK
|
||||
|
||||
final public class FeedFetchedResultsController {
|
||||
final public class FeedDataController {
|
||||
|
||||
@Published public var records: [MastodonFeed] = []
|
||||
|
||||
|
@ -81,7 +73,7 @@ final public class FeedFetchedResultsController {
|
|||
}
|
||||
}
|
||||
|
||||
private extension FeedFetchedResultsController {
|
||||
private extension FeedDataController {
|
||||
func load(kind: MastodonFeed.Kind, sinceId: MastodonStatus.ID?) async throws -> [MastodonFeed] {
|
||||
switch kind {
|
||||
case .home:
|
|
@ -1,17 +1,10 @@
|
|||
//
|
||||
// StatusFetchedResultsController.swift
|
||||
// Mastodon
|
||||
//
|
||||
// Created by MainasuK Cirno on 2021-3-30.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Combine
|
||||
import CoreData
|
||||
import CoreDataStack
|
||||
import MastodonSDK
|
||||
|
||||
public final class StatusFetchedResultsController {
|
||||
public final class StatusDataController {
|
||||
@MainActor
|
||||
@Published
|
||||
public private(set) var records: [MastodonStatus] = []
|
Loading…
Reference in New Issue