Skip to content

Commit d2baeae

Browse files
authored
Fix: resolve some project warnings (#1496)
* Remove CGSize conformance to Hashable, already provided by CoreGraphics * Fix APIService concurrency warnings by adding MainActor annotations to some extensions * Fix unused variable reference warning * Update to UNUserNotificationCenter to set badge count, replacing deprecated UIApplication call * Remove unused reference to self in SettingsService.init closure * Fix concurrency warning by adding MainActor annotation to AutoCompleteViewModel.State subclass * Fix concurrency warnings by removing await annotation for non-async functions in AutoCompleteViewModel+State
1 parent a93752d commit d2baeae

File tree

9 files changed

+14
-32
lines changed

9 files changed

+14
-32
lines changed

MastodonSDK/Sources/MastodonCore/Service/API/APIService+Bookmark.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ extension APIService {
5858

5959
}
6060

61-
extension APIService {
61+
@MainActor extension APIService {
6262
public func bookmarkedStatuses(
6363
limit: Int = onceRequestStatusMaxCount,
6464
maxID: String? = nil,

MastodonSDK/Sources/MastodonCore/Service/API/APIService+Favorite.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ extension APIService {
100100
}
101101
}
102102

103-
extension APIService {
103+
@MainActor extension APIService {
104104
public func favoritedStatuses(
105105
limit: Int = onceRequestStatusMaxCount,
106106
maxID: String? = nil,

MastodonSDK/Sources/MastodonCore/Service/API/APIService+HashtagTimeline.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import CoreData
1111
import CoreDataStack
1212
import MastodonSDK
1313

14-
extension APIService {
14+
@MainActor extension APIService {
1515

1616
public func hashtagTimeline(
1717
sinceID: Mastodon.Entity.Status.ID? = nil,

MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public extension Notification.Name {
1515
static let userFetched = Notification.Name(rawValue: "org.joinmastodon.app.user-fetched")
1616
}
1717

18-
extension APIService {
18+
@MainActor extension APIService {
1919

2020
public func homeTimeline(
2121
itemsNoOlderThan sinceID: Mastodon.Entity.Status.ID? = nil,

MastodonSDK/Sources/MastodonCore/Service/API/APIService+Status.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ extension APIService {
6262
) async throws -> Mastodon.Entity.Status {
6363
let authorization = authenticationBox.userAuthorization
6464

65-
let managedObjectContext = backgroundManagedObjectContext
6665
let _query: Mastodon.API.Statuses.DeleteStatusQuery? = Mastodon.API.Statuses.DeleteStatusQuery(id: postID)
6766
guard let query = _query else {
6867
throw APIError.implicit(.badRequest)

MastodonSDK/Sources/MastodonCore/Service/Notification/NotificationService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public final class NotificationService {
104104
}
105105

106106
UserDefaults.shared.notificationBadgeCount = count
107-
UIApplication.shared.applicationIconBadgeNumber = count
107+
UNUserNotificationCenter.current().setBadgeCount(count)
108108
Task { @MainActor in
109109
UIApplication.shared.shortcutItems = try? await self.unreadApplicationShortcutItems()
110110
}

MastodonSDK/Sources/MastodonCore/Service/SettingService.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ public final class SettingService {
3333

3434
// create setting (if non-exist) for authenticated users
3535
AuthenticationServiceProvider.shared.$mastodonAuthenticationBoxes
36-
.compactMap { [weak self] mastodonAuthenticationBoxes -> AnyPublisher<[MastodonAuthenticationBox], Never>? in
37-
guard let self = self else { return nil }
38-
36+
.compactMap { mastodonAuthenticationBoxes -> AnyPublisher<[MastodonAuthenticationBox], Never>? in
3937
let managedObjectContext = PersistenceManager.shared.backgroundManagedObjectContext
4038
return managedObjectContext.performChanges {
4139
for authenticationBox in mastodonAuthenticationBoxes {

MastodonSDK/Sources/MastodonUI/Extension/CGSize+Hashable.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewModel+State.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension AutoCompleteViewModel {
2929
}
3030

3131
extension AutoCompleteViewModel.State {
32-
class Initial: AutoCompleteViewModel.State {
32+
@MainActor class Initial: AutoCompleteViewModel.State {
3333
override func isValidNextState(_ stateClass: AnyClass) -> Bool {
3434
guard let viewModel = viewModel else { return false }
3535
switch stateClass {
@@ -84,17 +84,17 @@ extension AutoCompleteViewModel.State {
8484

8585
private func fetchLocalEmoji(searchText: String) async {
8686
guard let viewModel = viewModel else {
87-
await enter(state: Fail.self)
87+
enter(state: Fail.self)
8888
return
8989
}
9090

9191
guard let customEmojiViewModel = viewModel.customEmojiViewModel else {
92-
await enter(state: Fail.self)
92+
enter(state: Fail.self)
9393
return
9494
}
9595

9696
guard let emojiTrie = customEmojiViewModel.emojiTrie.value else {
97-
await enter(state: Fail.self)
97+
enter(state: Fail.self)
9898
return
9999
}
100100

@@ -108,13 +108,13 @@ extension AutoCompleteViewModel.State {
108108
AutoCompleteItem.emoji(emoji: emoji)
109109
}
110110

111-
await enter(state: Idle.self)
111+
enter(state: Idle.self)
112112
viewModel.autoCompleteItems.value = items
113113
}
114114

115115
private func queryRemoteEnitity(searchText: String) async {
116116
guard let viewModel = viewModel else {
117-
await enter(state: Fail.self)
117+
enter(state: Fail.self)
118118
return
119119
}
120120

@@ -136,7 +136,7 @@ extension AutoCompleteViewModel.State {
136136
authenticationBox: viewModel.authenticationBox
137137
)
138138

139-
await enter(state: Idle.self)
139+
enter(state: Idle.self)
140140

141141
guard viewModel.inputText.value == searchText else { return } // discard if not matching
142142

@@ -147,7 +147,7 @@ extension AutoCompleteViewModel.State {
147147
viewModel.autoCompleteItems.value = items
148148

149149
} catch {
150-
await enter(state: Fail.self)
150+
enter(state: Fail.self)
151151
}
152152
}
153153

0 commit comments

Comments
 (0)