mastodon-ios/Mastodon/Protocol/Provider/DataSourceFacade+Bookmark.s...

33 lines
950 B
Swift
Raw Normal View History

//
// DataSourceFacade+Bookmark.swift
// Mastodon
//
// Created by ProtoLimit on 2022/07/29.
//
import UIKit
import CoreData
import CoreDataStack
2022-10-08 07:43:06 +02:00
import MastodonCore
2023-11-22 12:32:04 +01:00
import MastodonSDK
extension DataSourceFacade {
2022-10-08 07:43:06 +02:00
public static func responseToStatusBookmarkAction(
provider: NeedsDependency & AuthContextProvider & DataSourceProvider,
2023-11-22 12:32:04 +01:00
status: MastodonStatus
) async throws {
let selectionFeedbackGenerator = await UISelectionFeedbackGenerator()
await selectionFeedbackGenerator.selectionChanged()
2023-11-28 11:13:13 +01:00
let updatedStatus = try await provider.context.apiService.bookmark(
record: status,
authenticationBox: provider.authContext.mastodonAuthenticationBox
2023-11-28 11:13:13 +01:00
).value
let newStatus: MastodonStatus = .fromEntity(updatedStatus)
newStatus.isSensitiveToggled = status.isSensitiveToggled
provider.update(status: newStatus)
}
}