mastodon-ios/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewModel.swift

34 lines
1018 B
Swift
Raw Normal View History

2021-07-15 14:28:36 +02:00
//
// SearchHistoryViewModel.swift
// Mastodon
//
// Created by MainasuK Cirno on 2021-7-15.
//
import UIKit
import Combine
import CoreDataStack
2022-10-08 07:43:06 +02:00
import MastodonCore
2021-07-15 14:28:36 +02:00
final class SearchHistoryViewModel {
2021-07-15 14:28:36 +02:00
var disposeBag = Set<AnyCancellable>()
// input
let context: AppContext
let authContext: AuthContext
2021-07-15 14:28:36 +02:00
let searchHistoryFetchedResultController: SearchHistoryFetchedResultController
// output
var diffableDataSource: UICollectionViewDiffableDataSource<SearchHistorySection, SearchHistoryItem>?
init(context: AppContext, authContext: AuthContext) {
2021-07-15 14:28:36 +02:00
self.context = context
self.authContext = authContext
2021-07-15 14:28:36 +02:00
self.searchHistoryFetchedResultController = SearchHistoryFetchedResultController(managedObjectContext: context.managedObjectContext)
searchHistoryFetchedResultController.domain.value = authContext.mastodonAuthenticationBox.domain
searchHistoryFetchedResultController.userID.value = authContext.mastodonAuthenticationBox.userID
2021-07-15 14:28:36 +02:00
}
}