2022-07-29 22:31:38 +02:00
|
|
|
//
|
|
|
|
// 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
|
2024-01-08 11:17:40 +01:00
|
|
|
import MastodonSDK
|
2022-07-29 22:31:38 +02:00
|
|
|
|
|
|
|
extension DataSourceFacade {
|
2024-01-30 23:02:13 +01:00
|
|
|
@MainActor
|
2022-10-08 07:43:06 +02:00
|
|
|
public static func responseToStatusBookmarkAction(
|
2024-01-08 11:17:40 +01:00
|
|
|
provider: NeedsDependency & AuthContextProvider & DataSourceProvider,
|
|
|
|
status: MastodonStatus
|
2022-07-29 22:31:38 +02:00
|
|
|
) async throws {
|
2024-01-30 23:02:13 +01:00
|
|
|
let selectionFeedbackGenerator = UISelectionFeedbackGenerator()
|
|
|
|
selectionFeedbackGenerator.selectionChanged()
|
2022-07-29 22:31:38 +02:00
|
|
|
|
2024-01-08 11:17:40 +01:00
|
|
|
let updatedStatus = try await provider.context.apiService.bookmark(
|
2022-07-29 22:31:38 +02:00
|
|
|
record: status,
|
2022-10-09 14:07:57 +02:00
|
|
|
authenticationBox: provider.authContext.mastodonAuthenticationBox
|
2024-01-08 11:17:40 +01:00
|
|
|
).value
|
|
|
|
|
|
|
|
let newStatus: MastodonStatus = .fromEntity(updatedStatus)
|
|
|
|
newStatus.isSensitiveToggled = status.isSensitiveToggled
|
|
|
|
|
2024-01-30 23:02:13 +01:00
|
|
|
provider.update(status: newStatus, intent: .bookmark(updatedStatus.bookmarked == true))
|
2022-07-29 22:31:38 +02:00
|
|
|
}
|
|
|
|
}
|