Use constant foe UserInfo-key instead of string (IOS-192)

This commit is contained in:
Nathan Mattes 2024-02-19 10:18:12 +01:00
parent 7f2d459ccb
commit 0e46a811b7
6 changed files with 16 additions and 9 deletions

View File

@ -27,7 +27,7 @@ extension DataSourceFacade {
)
let userInfo = [
"relationship": response.value,
.relationship: response.value,
]
NotificationCenter.default.post(name: .relationshipChanged, object: self, userInfo: userInfo)

View File

@ -27,7 +27,7 @@ extension DataSourceFacade {
dependency.context.authenticationService.fetchFollowingAndBlockedAsync()
NotificationCenter.default.post(name: .relationshipChanged, object: nil, userInfo: [
"relationship": response
.relationship: response
])
return response
@ -75,7 +75,7 @@ extension DataSourceFacade {
}
NotificationCenter.default.post(name: .relationshipChanged, object: nil, userInfo: [
"relationship": newRelationship
.relationship: newRelationship
])
await notificationView.configure(notification: notification, authenticationBox: dependency.authContext.mastodonAuthenticationBox)
@ -115,7 +115,7 @@ extension DataSourceFacade {
)
let userInfo = [
"relationship": newRelationship,
.relationship: newRelationship,
]
NotificationCenter.default.post(name: .relationshipChanged, object: self, userInfo: userInfo)

View File

@ -23,7 +23,7 @@ extension DataSourceFacade {
)
let userInfo = [
"relationship": response.value,
.relationship: response.value,
]
NotificationCenter.default.post(name: .relationshipChanged, object: self, userInfo: userInfo)

View File

@ -833,7 +833,7 @@ extension ProfileViewController: ProfileHeaderViewControllerDelegate {
// we need to trigger this here as domain block doesn't return a relationship
let userInfo = [
"relationship": newRelationship,
.relationship: newRelationship,
]
NotificationCenter.default.post(name: .relationshipChanged, object: self, userInfo: userInfo)
@ -1002,7 +1002,7 @@ extension ProfileViewController {
@objc
func relationshipChanged(_ notification: Notification) {
guard let userInfo = notification.userInfo, let relationship = userInfo["relationship"] as? Mastodon.Entity.Relationship else {
guard let userInfo = notification.userInfo, let relationship = userInfo[.relationship] as? Mastodon.Entity.Relationship else {
return
}

View File

@ -11,9 +11,8 @@ import CoreData
import CoreDataStack
import MastodonSDK
public extension Foundation.Notification.Name {
public extension Notification.Name {
static let userFetched = Notification.Name(rawValue: "org.joinmastodon.app.user-fetched")
static let relationshipChanged = Notification.Name(rawValue: "org.joinmastodon.app.relationship-changed")
}
extension APIService {

View File

@ -11,6 +11,14 @@ import CoreData
import CoreDataStack
import MastodonSDK
extension Notification.Name {
public static let relationshipChanged = Notification.Name(rawValue: "org.joinmastodon.app.relationship-changed")
}
extension AnyHashable {
public static let relationship = "relationship"
}
extension APIService {
public func relationship(
forAccounts accounts: [Mastodon.Entity.Account],