From 624c3226d5299f055f5d6916f1a2233e1c674959 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Thu, 30 Nov 2023 15:41:05 +0100 Subject: [PATCH 1/3] Only search for relationships if there are accounts (#1187) Otherwise this would lead to a `badRequest` --- .../SearchResult/SearchResultViewModel+State.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel+State.swift b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel+State.swift index fef37ce04..f9bdb2baa 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel+State.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewModel+State.swift @@ -125,10 +125,15 @@ extension SearchResultViewModel.State { let accounts = searchResults.accounts - let relationships = try await viewModel.context.apiService.relationship( - forAccounts: accounts, - authenticationBox: viewModel.authContext.mastodonAuthenticationBox - ).value + let relationships: [Mastodon.Entity.Relationship] + if accounts.isNotEmpty { + relationships = try await viewModel.context.apiService.relationship( + forAccounts: accounts, + authenticationBox: viewModel.authContext.mastodonAuthenticationBox + ).value + } else { + relationships = [] + } let statusIDs = searchResults.statuses.map { $0.id } From 5928592aa79c842b8f602ce815962389f19f192e Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Thu, 30 Nov 2023 16:35:53 +0100 Subject: [PATCH 2/3] Don't throw when one account can't be authenticated (#1178) --- .../MastodonCore/Service/API/APIService+HomeTimeline.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift index 5317cd4b0..0ba55beb2 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift @@ -46,8 +46,9 @@ extension APIService { // FIXME: This is a dirty hack to make the performance-stuff work. // Problem is, that we don't persist the user on disk anymore. So we have to fetch // it when we need it to display on the home timeline. + // We need this (also) for the Account-list, but it might be the wrong place. App Startup might be more appropriate for authentication in AuthenticationServiceProvider.shared.authentications { - _ = try await accountInfo(domain: authentication.domain, + _ = try await? accountInfo(domain: authentication.domain, userID: authentication.userID, authorization: Mastodon.API.OAuth.Authorization(accessToken: authentication.userAccessToken)).value } From 7b8898a1aecf3e92234241e257673a6c758a304c Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Thu, 30 Nov 2023 16:39:43 +0100 Subject: [PATCH 3/3] :facepalm: (#1178) --- .../MastodonCore/Service/API/APIService+HomeTimeline.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift index 0ba55beb2..f806f856f 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+HomeTimeline.swift @@ -48,7 +48,7 @@ extension APIService { // it when we need it to display on the home timeline. // We need this (also) for the Account-list, but it might be the wrong place. App Startup might be more appropriate for authentication in AuthenticationServiceProvider.shared.authentications { - _ = try await? accountInfo(domain: authentication.domain, + _ = try? await accountInfo(domain: authentication.domain, userID: authentication.userID, authorization: Mastodon.API.OAuth.Authorization(accessToken: authentication.userAccessToken)).value }