2
2
mirror of https://github.com/mastodon/mastodon-ios synced 2025-04-11 22:58:02 +02:00
mastodon-ios/Mastodon/Protocol/Provider/DataSourceFacade+SearchHistory.swift
Nathan Mattes 59c6d31ca4 [WIP] Remove CoreData for Tags/Accounts in Search (IOS-196)
- Add basic, json-based persistence (it's WIP and pragmatic aka dirty, see FileManager+SearchHistory)
2023-11-23 13:58:56 +01:00

53 lines
1.4 KiB
Swift

//
// DataSourceFacade+SearchHistory.swift
// Mastodon
//
// Created by MainasuK on 2022-1-20.
//
import Foundation
import CoreDataStack
import MastodonCore
import UIKit
extension DataSourceFacade {
static func responseToCreateSearchHistory(
provider: ViewControllerWithDependencies & AuthContextProvider,
item: DataSourceItem
) async {
switch item {
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
)
try? FileManager.default.addSearchItem(searchEntry)
case .hashtag(let tag):
let now = Date()
let userID = provider.authContext.mastodonAuthenticationBox.userID
let searchEntry = Persistence.SearchHistory.Item(
updatedAt: now,
userID: userID,
account: nil,
hashtag: tag
)
try? FileManager.default.addSearchItem(searchEntry)
case .status:
break
case .user(_):
break
case .notification:
break
}
}
}