From 624c3226d5299f055f5d6916f1a2233e1c674959 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Thu, 30 Nov 2023 15:41:05 +0100 Subject: [PATCH] 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 }