From 778b44ecf4fe150b9478a33cc5fbcf418d0df84d Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Thu, 21 Sep 2023 13:10:17 +0200 Subject: [PATCH] Fix warnings --- .../Discovery/Posts/DiscoveryPostsViewModel+State.swift | 7 ------- .../HashtagTimeline/HashtagTimelineViewModel+State.swift | 7 ------- .../HomeTimelineViewModel+LoadLatestState.swift | 3 --- .../HomeTimelineViewModel+LoadOldestState.swift | 7 ------- .../NotificationTimelineViewModel+LoadOldestState.swift | 7 ------- .../MastodonConfirmEmailViewController.swift | 4 ++-- .../Onboarding/Login/MastodonLoginViewController.swift | 5 ----- .../Scene/Profile/Bookmark/BookmarkViewModel+State.swift | 7 ------- .../Scene/Profile/Favorite/FavoriteViewModel+State.swift | 9 +-------- .../Profile/Follower/FollowerListViewModel+State.swift | 7 ------- .../Profile/Following/FollowingListViewModel+State.swift | 7 ------- Mastodon/Scene/Profile/RemoteProfileViewModel.swift | 4 ++-- .../Profile/Timeline/UserTimelineViewModel+State.swift | 7 ------- .../Scene/Profile/UserLIst/UserListViewModel+State.swift | 7 ------- .../Scene/Thread/ThreadViewModel+LoadThreadState.swift | 7 ------- Mastodon/Supporting Files/AppDelegate.swift | 3 --- MastodonSDK/Sources/MastodonCore/AuthContext.swift | 2 +- .../MastodonCore/Service/API/APIService+Account.swift | 6 ------ .../Sources/MastodonCore/Service/InstanceService.swift | 2 +- .../MastodonCore/Service/StatusFilterService.swift | 2 +- .../AutoComplete/AutoCompleteViewModel+State.swift | 7 ------- .../Scene/ComposeContent/ComposeContentViewModel.swift | 2 +- 22 files changed, 9 insertions(+), 110 deletions(-) diff --git a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+State.swift b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+State.swift index 7169b8347..75794258d 100644 --- a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+State.swift +++ b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+State.swift @@ -20,13 +20,6 @@ extension DiscoveryPostsViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+State.swift b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+State.swift index 5913871f2..579060bda 100644 --- a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+State.swift +++ b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewModel+State.swift @@ -24,13 +24,6 @@ extension HashtagTimelineViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift index 5cce90694..7f056928c 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadLatestState.swift @@ -29,7 +29,6 @@ extension HomeTimelineViewModel { override func didEnter(from previousState: GKState?) { super.didEnter(from: previousState) - let previousState = previousState as? HomeTimelineViewModel.LoadLatestState viewModel?.loadLatestStateMachinePublisher.send(self) } @@ -90,12 +89,10 @@ extension HomeTimelineViewModel.LoadLatestState { managedObjectContext.parent = parentManagedObjectContext Task { - let start = CACurrentMediaTime() let latestStatusIDs: [Status.ID] = latestFeedRecords.compactMap { record in guard let feed = record.object(in: managedObjectContext) else { return nil } return feed.status?.id } - let end = CACurrentMediaTime() do { let response = try await viewModel.context.apiService.homeTimeline( diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift index cf58f06ba..1b6e4499d 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+LoadOldestState.swift @@ -20,13 +20,6 @@ extension HomeTimelineViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - @MainActor func enter(state: LoadOldestState.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+LoadOldestState.swift b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+LoadOldestState.swift index fe72df772..3be724701 100644 --- a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+LoadOldestState.swift +++ b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel+LoadOldestState.swift @@ -21,13 +21,6 @@ extension NotificationTimelineViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - @MainActor func enter(state: LoadOldestState.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift b/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift index 64a1f2d5e..62a861f8c 100644 --- a/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift +++ b/Mastodon/Scene/Onboarding/ConfirmEmail/MastodonConfirmEmailViewController.swift @@ -103,7 +103,7 @@ extension MastodonConfirmEmailViewController { .receive(on: DispatchQueue.main) .sink { completion in switch completion { - case .failure(let error): + case .failure(_): break case .finished: // upload avatar and set display name in the background @@ -118,7 +118,7 @@ extension MastodonConfirmEmailViewController { .retry(3) .sink { completion in switch completion { - case .failure(let error): + case .failure(_): break case .finished: break diff --git a/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift b/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift index 839750145..86ff2c269 100644 --- a/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift +++ b/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift @@ -228,15 +228,10 @@ class MastodonLoginViewController: UIViewController, NeedsDependency { @objc func keyboardWillShowNotification(_ notification: Notification) { guard let userInfo = notification.userInfo, - let keyboardFrameValue = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue, let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber else { return } // inspired by https://stackoverflow.com/a/30245044 - let keyboardFrame = keyboardFrameValue.cgRectValue - - let keyboardOrigin = view.convert(keyboardFrame.origin, from: nil) - UIView.animate(withDuration: duration.doubleValue, delay: 0, options: .curveEaseInOut) { self.view.layoutIfNeeded() } diff --git a/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+State.swift b/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+State.swift index 5ec4761cd..f746a5acb 100644 --- a/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+State.swift +++ b/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+State.swift @@ -21,13 +21,6 @@ extension BookmarkViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+State.swift b/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+State.swift index c4fad013f..a1a8d0f99 100644 --- a/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+State.swift +++ b/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+State.swift @@ -20,14 +20,7 @@ extension FavoriteViewModel { init(viewModel: FavoriteViewModel) { self.viewModel = viewModel } - - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - + @MainActor func enter(state: State.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift b/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift index f8a47aab6..fb7b20166 100644 --- a/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift +++ b/Mastodon/Scene/Profile/Follower/FollowerListViewModel+State.swift @@ -26,13 +26,6 @@ extension FollowerListViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift b/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift index b21de6be3..df71c0d7c 100644 --- a/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift +++ b/Mastodon/Scene/Profile/Following/FollowingListViewModel+State.swift @@ -20,13 +20,6 @@ extension FollowingListViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Scene/Profile/RemoteProfileViewModel.swift b/Mastodon/Scene/Profile/RemoteProfileViewModel.swift index bc35a218c..832c25858 100644 --- a/Mastodon/Scene/Profile/RemoteProfileViewModel.swift +++ b/Mastodon/Scene/Profile/RemoteProfileViewModel.swift @@ -30,7 +30,7 @@ final class RemoteProfileViewModel: ProfileViewModel { .receive(on: DispatchQueue.main) .sink { completion in switch completion { - case .failure(let error): + case .failure(_): // TODO: handle error break case .finished: @@ -106,7 +106,7 @@ final class RemoteProfileViewModel: ProfileViewModel { .receive(on: DispatchQueue.main) .sink { completion in switch completion { - case .failure(let error): + case .failure(_): // TODO: handle error break case .finished: diff --git a/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+State.swift b/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+State.swift index 4d5af3cdf..cd0110a87 100644 --- a/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+State.swift +++ b/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+State.swift @@ -20,13 +20,6 @@ extension UserTimelineViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Scene/Profile/UserLIst/UserListViewModel+State.swift b/Mastodon/Scene/Profile/UserLIst/UserListViewModel+State.swift index 6f0c394b0..cb6e9d3fa 100644 --- a/Mastodon/Scene/Profile/UserLIst/UserListViewModel+State.swift +++ b/Mastodon/Scene/Profile/UserLIst/UserListViewModel+State.swift @@ -20,13 +20,6 @@ extension UserListViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift b/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift index 9ef713bcc..09411e88a 100644 --- a/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift +++ b/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift @@ -22,13 +22,6 @@ extension ThreadViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - @MainActor func enter(state: LoadThreadState.Type) { stateMachine?.enter(state) diff --git a/Mastodon/Supporting Files/AppDelegate.swift b/Mastodon/Supporting Files/AppDelegate.swift index 2269f9c54..2e67532eb 100644 --- a/Mastodon/Supporting Files/AppDelegate.swift +++ b/Mastodon/Supporting Files/AppDelegate.swift @@ -82,8 +82,6 @@ extension AppDelegate: UNUserNotificationCenterDelegate { return } - let notificationID = String(pushNotification.notificationID) - let accessToken = pushNotification.accessToken UserDefaults.shared.increaseNotificationCount(accessToken: accessToken) appContext.notificationService.applicationIconBadgeNeedsUpdate.send() @@ -112,7 +110,6 @@ extension AppDelegate: UNUserNotificationCenterDelegate { return } - let notificationID = String(pushNotification.notificationID) appContext.notificationService.handle(pushNotification: pushNotification) appContext.notificationService.requestRevealNotificationPublisher.send(pushNotification) completionHandler() diff --git a/MastodonSDK/Sources/MastodonCore/AuthContext.swift b/MastodonSDK/Sources/MastodonCore/AuthContext.swift index adb98d88f..6dce8f758 100644 --- a/MastodonSDK/Sources/MastodonCore/AuthContext.swift +++ b/MastodonSDK/Sources/MastodonCore/AuthContext.swift @@ -37,7 +37,7 @@ extension AuthContext { .sink { [weak self] completion in guard let self = self else { return } switch completion { - case .failure(let error): + case .failure(_): break case .finished: break diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift index 74285c8ec..d9d6b97b1 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift @@ -45,8 +45,6 @@ extension APIService { networkDate: response.networkDate ) ) - - let flag = result.isNewInsertion ? "+" : "-" } return response @@ -79,7 +77,6 @@ extension APIService { networkDate: response.networkDate ) ) - let flag = result.isNewInsertion ? "+" : "-" } .setFailureType(to: Error.self) .tryMap { result -> Mastodon.Response.Content in @@ -118,9 +115,6 @@ extension APIService { networkDate: response.networkDate ) ) - let flag = result.isNewInsertion ? "+" : "-" - let userID = response.value.id - let username = response.value.username } return response diff --git a/MastodonSDK/Sources/MastodonCore/Service/InstanceService.swift b/MastodonSDK/Sources/MastodonCore/Service/InstanceService.swift index e9ca2df9e..20c0f793e 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/InstanceService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/InstanceService.swift @@ -62,7 +62,7 @@ extension InstanceService { .sink { [weak self] completion in guard let self = self else { return } switch completion { - case .failure(let error): + case .failure(_): break case .finished: break diff --git a/MastodonSDK/Sources/MastodonCore/Service/StatusFilterService.swift b/MastodonSDK/Sources/MastodonCore/Service/StatusFilterService.swift index 16d4be05e..6be64bcba 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/StatusFilterService.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/StatusFilterService.swift @@ -75,7 +75,7 @@ public final class StatusFilterService { switch result { case .success(let response): self.activeFilters = response.value - case .failure(let error): + case .failure(_): break } } diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewModel+State.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewModel+State.swift index bb315a6e8..52f1792cb 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewModel+State.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewModel+State.swift @@ -21,13 +21,6 @@ extension AutoCompleteViewModel { self.viewModel = viewModel } - override func didEnter(from previousState: GKState?) { - super.didEnter(from: previousState) - - let from = previousState.flatMap { String(describing: $0) } ?? "nil" - let to = String(describing: self) - } - @MainActor func enter(state: State.Type) { stateMachine?.enter(state) diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift index 515e3d243..7a97d3e26 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift @@ -782,7 +782,7 @@ extension ComposeContentViewModel: AttachmentViewModelDelegate { @MainActor func uploadMediaInQueue() async throws { - for (i, attachmentViewModel) in attachmentViewModels.enumerated() { + for (_, attachmentViewModel) in attachmentViewModels.enumerated() { switch attachmentViewModel.uploadState { case .none: return