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
|
|
|
|
2023-05-09 11:33:31 +02:00
|
|
|
final class SearchHistoryViewModel {
|
2021-07-15 14:28:36 +02:00
|
|
|
var disposeBag = Set<AnyCancellable>()
|
|
|
|
|
|
|
|
// input
|
|
|
|
let context: AppContext
|
2022-10-09 14:07:57 +02:00
|
|
|
let authContext: AuthContext
|
2021-07-15 14:28:36 +02:00
|
|
|
let searchHistoryFetchedResultController: SearchHistoryFetchedResultController
|
|
|
|
|
|
|
|
// output
|
2022-01-27 14:23:39 +01:00
|
|
|
var diffableDataSource: UICollectionViewDiffableDataSource<SearchHistorySection, SearchHistoryItem>?
|
2023-05-09 11:33:31 +02:00
|
|
|
|
2022-10-09 14:07:57 +02:00
|
|
|
init(context: AppContext, authContext: AuthContext) {
|
2021-07-15 14:28:36 +02:00
|
|
|
self.context = context
|
2022-10-09 14:07:57 +02:00
|
|
|
self.authContext = authContext
|
2021-07-15 14:28:36 +02:00
|
|
|
self.searchHistoryFetchedResultController = SearchHistoryFetchedResultController(managedObjectContext: context.managedObjectContext)
|
|
|
|
|
2022-10-09 14:07:57 +02:00
|
|
|
searchHistoryFetchedResultController.domain.value = authContext.mastodonAuthenticationBox.domain
|
|
|
|
searchHistoryFetchedResultController.userID.value = authContext.mastodonAuthenticationBox.userID
|
2021-07-15 14:28:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|