2022-01-27 14:23:39 +01:00
|
|
|
//
|
|
|
|
// DataSourceFacade+SearchHistory.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-1-20.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import CoreDataStack
|
2022-10-08 07:43:06 +02:00
|
|
|
import MastodonCore
|
2023-09-17 13:52:35 +02:00
|
|
|
import UIKit
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
extension DataSourceFacade {
|
2023-11-23 13:58:56 +01:00
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
static func responseToCreateSearchHistory(
|
2023-09-20 18:56:34 +02:00
|
|
|
provider: ViewControllerWithDependencies & AuthContextProvider,
|
2022-01-27 14:23:39 +01:00
|
|
|
item: DataSourceItem
|
|
|
|
) async {
|
|
|
|
switch item {
|
2023-11-23 13:58:56 +01:00
|
|
|
case .account(account: let account, relationship: _):
|
|
|
|
let now = Date()
|
|
|
|
let userID = provider.authContext.mastodonAuthenticationBox.userID
|
|
|
|
let searchEntry = Persistence.SearchHistory.Item(
|
|
|
|
updatedAt: now,
|
|
|
|
userID: userID,
|
|
|
|
account: account,
|
|
|
|
hashtag: nil
|
2022-01-27 14:23:39 +01:00
|
|
|
)
|
|
|
|
|
2023-12-28 22:39:24 +01:00
|
|
|
try? FileManager.default.addSearchItem(searchEntry, for: provider.authContext.mastodonAuthenticationBox)
|
2023-11-23 13:58:56 +01:00
|
|
|
case .hashtag(let tag):
|
2022-01-27 14:23:39 +01:00
|
|
|
|
2023-11-23 13:58:56 +01:00
|
|
|
let now = Date()
|
|
|
|
let userID = provider.authContext.mastodonAuthenticationBox.userID
|
|
|
|
let searchEntry = Persistence.SearchHistory.Item(
|
|
|
|
updatedAt: now,
|
|
|
|
userID: userID,
|
|
|
|
account: nil,
|
|
|
|
hashtag: tag
|
|
|
|
)
|
2022-01-27 14:23:39 +01:00
|
|
|
|
2023-12-28 22:39:24 +01:00
|
|
|
try? FileManager.default.addSearchItem(searchEntry, for: provider.authContext.mastodonAuthenticationBox)
|
2023-11-23 13:58:56 +01:00
|
|
|
case .status:
|
|
|
|
break
|
|
|
|
case .notification:
|
|
|
|
break
|
2022-01-27 14:23:39 +01:00
|
|
|
|
2023-11-23 13:58:56 +01:00
|
|
|
}
|
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|