From aee6459bcf1db184b8f044e2b5d772c032fa6230 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Mon, 1 Jan 2024 21:29:28 +0100 Subject: [PATCH] Status detail: Don't cancel the task --- .../Status/Detail/StatusDetailView.swift | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Packages/Status/Sources/Status/Detail/StatusDetailView.swift b/Packages/Status/Sources/Status/Detail/StatusDetailView.swift index 59ef44e3..89763f37 100644 --- a/Packages/Status/Sources/Status/Detail/StatusDetailView.swift +++ b/Packages/Status/Sources/Status/Detail/StatusDetailView.swift @@ -81,19 +81,21 @@ public struct StatusDetailView: View { proxy.scrollTo(newValue, anchor: .top) } } - .task { + .onAppear { guard !isLoaded else { return } viewModel.client = client viewModel.routerPath = routerPath - let result = await viewModel.fetch() - isLoaded = true + Task { + let result = await viewModel.fetch() + isLoaded = true - if !result { - if let url = viewModel.remoteStatusURL { - await UIApplication.shared.open(url) - } - DispatchQueue.main.async { - _ = routerPath.path.popLast() + if !result { + if let url = viewModel.remoteStatusURL { + await UIApplication.shared.open(url) + } + DispatchQueue.main.async { + _ = routerPath.path.popLast() + } } } }