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
|
2023-11-22 12:32:04 +01:00
|
|
|
import MastodonSDK
|
2022-07-29 22:31:38 +02:00
|
|
|
|
|
|
|
extension DataSourceFacade {
|
2022-10-08 07:43:06 +02:00
|
|
|
public static func responseToStatusBookmarkAction(
|
2023-12-27 10:32:14 +01:00
|
|
|
provider: NeedsDependency & AuthContextProvider & DataSourceProvider,
|
2023-11-22 12:32:04 +01:00
|
|
|
status: MastodonStatus
|
2022-07-29 22:31:38 +02:00
|
|
|
) 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(
|
2022-07-29 22:31:38 +02:00
|
|
|
record: status,
|
2022-10-09 14:07:57 +02:00
|
|
|
authenticationBox: provider.authContext.mastodonAuthenticationBox
|
2023-11-28 11:13:13 +01:00
|
|
|
).value
|
|
|
|
|
2023-12-01 09:52:41 +01:00
|
|
|
let newStatus: MastodonStatus = .fromEntity(updatedStatus)
|
|
|
|
newStatus.isSensitiveToggled = status.isSensitiveToggled
|
|
|
|
|
|
|
|
provider.update(status: newStatus)
|
2022-07-29 22:31:38 +02:00
|
|
|
}
|
|
|
|
}
|