From 25470e61e5ee7a09fb1e33add9c7f9f7980b3f2d Mon Sep 17 00:00:00 2001 From: Davide Date: Sun, 20 Oct 2024 01:54:46 +0200 Subject: [PATCH] Lazy-load tunnel logs in Diagnostics Fixes #743 --- .../Views/Diagnostics/DiagnosticsView.swift | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/DiagnosticsView.swift b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/DiagnosticsView.swift index 35c01381..28bfbf8d 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/DiagnosticsView.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/DiagnosticsView.swift @@ -50,14 +50,16 @@ struct DiagnosticsView: View { @AppStorage(AppPreference.logsPrivateData.key, store: .appGroup) private var logsPrivateData = false - var availableTunnelLogs: () -> [LogEntry] = { - PassepartoutConfiguration.shared.availableLogs(at: BundleConfiguration.urlForTunnelLog) - .sorted { - $0.key > $1.key - } - .map { - LogEntry(date: $0, url: $1) - } + var availableTunnelLogs: () async -> [LogEntry] = { + await Task.detached { + PassepartoutConfiguration.shared.availableLogs(at: BundleConfiguration.urlForTunnelLog) + .sorted { + $0.key > $1.key + } + .map { + LogEntry(date: $0, url: $1) + } + }.value } @State @@ -81,8 +83,8 @@ struct DiagnosticsView: View { reportIssueSection } } - .onLoad { - tunnelLogs = availableTunnelLogs() + .task { + tunnelLogs = await availableTunnelLogs() } .themeForm() .navigationTitle(Strings.Views.Diagnostics.title)