2022-01-27 14:23:39 +01:00
|
|
|
//
|
|
|
|
// DataSourceFacade+Block.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-1-24.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import CoreDataStack
|
2022-10-08 07:43:06 +02:00
|
|
|
import MastodonCore
|
2023-10-19 14:39:07 +02:00
|
|
|
import MastodonSDK
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
extension DataSourceFacade {
|
|
|
|
static func responseToUserBlockAction(
|
2022-10-09 14:07:57 +02:00
|
|
|
dependency: NeedsDependency & AuthContextProvider,
|
2023-12-14 14:07:42 +01:00
|
|
|
account: Mastodon.Entity.Account
|
2023-12-25 14:38:11 +01:00
|
|
|
) async throws -> Mastodon.Entity.Relationship {
|
2023-10-19 14:39:07 +02:00
|
|
|
let selectionFeedbackGenerator = await UISelectionFeedbackGenerator()
|
|
|
|
await selectionFeedbackGenerator.selectionChanged()
|
|
|
|
|
|
|
|
let apiService = dependency.context.apiService
|
|
|
|
let authBox = dependency.authContext.mastodonAuthenticationBox
|
|
|
|
|
2023-12-25 14:38:11 +01:00
|
|
|
let response = try await apiService.toggleBlock(
|
2023-12-27 23:48:16 +01:00
|
|
|
account: account,
|
2023-10-19 14:39:07 +02:00
|
|
|
authenticationBox: authBox
|
|
|
|
)
|
|
|
|
|
2024-02-16 12:16:55 +01:00
|
|
|
let userInfo = [
|
2024-02-19 12:05:34 +01:00
|
|
|
UserInfoKey.relationship: response.value,
|
2024-02-16 12:16:55 +01:00
|
|
|
]
|
2023-12-25 14:38:11 +01:00
|
|
|
|
2024-02-16 12:16:55 +01:00
|
|
|
NotificationCenter.default.post(name: .relationshipChanged, object: self, userInfo: userInfo)
|
2023-12-25 14:38:11 +01:00
|
|
|
|
|
|
|
return response.value
|
2023-10-19 14:39:07 +02:00
|
|
|
}
|
2023-12-18 19:59:22 +01:00
|
|
|
|
|
|
|
static func responseToDomainBlockAction(
|
|
|
|
dependency: NeedsDependency & AuthContextProvider,
|
2024-01-02 12:15:15 +01:00
|
|
|
account: Mastodon.Entity.Account
|
|
|
|
) async throws -> Mastodon.Entity.Empty {
|
2023-12-18 19:59:22 +01:00
|
|
|
let selectionFeedbackGenerator = await UISelectionFeedbackGenerator()
|
|
|
|
await selectionFeedbackGenerator.selectionChanged()
|
|
|
|
|
|
|
|
let apiService = dependency.context.apiService
|
|
|
|
let authBox = dependency.authContext.mastodonAuthenticationBox
|
|
|
|
|
2024-01-02 12:15:15 +01:00
|
|
|
let response = try await apiService.toggleDomainBlock(account: account, authenticationBox: authBox)
|
|
|
|
|
|
|
|
return response.value
|
2023-12-18 19:59:22 +01:00
|
|
|
}
|
2022-01-27 14:23:39 +01:00
|
|
|
}
|