From 38b7eaa0b2990a2b5283fd4b4821c9e6d69e9d96 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Sat, 31 Dec 2022 06:37:13 +0100 Subject: [PATCH] Sync embed load --- Packages/Status/Sources/Status/Row/StatusRowViewModel.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift b/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift index 4fa825ef..4058dc35 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift @@ -50,16 +50,18 @@ public class StatusRowViewModel: ObservableObject { withAnimation { isEmbedLoading = true } + var embed: Status? if url.absoluteString.contains(client.server), let id = Int(url.lastPathComponent) { - self.embededStatus = try await client.get(endpoint: Statuses.status(id: String(id))) + embed = try await client.get(endpoint: Statuses.status(id: String(id))) } else { let results: SearchResults = try await client.get(endpoint: Search.search(query: url.absoluteString, type: "statuses", offset: 0), forceVersion: .v2) - self.embededStatus = results.statuses.first + embed = results.statuses.first } withAnimation { + embededStatus = embed isEmbedLoading = false } } catch {