Lazy-load tunnel logs in Diagnostics

Fixes #743
This commit is contained in:
Davide 2024-10-20 01:54:46 +02:00
parent ae9e200618
commit 25470e61e5
No known key found for this signature in database
GPG Key ID: A48836171C759F5E
1 changed files with 12 additions and 10 deletions

View File

@ -50,7 +50,8 @@ struct DiagnosticsView: View {
@AppStorage(AppPreference.logsPrivateData.key, store: .appGroup) @AppStorage(AppPreference.logsPrivateData.key, store: .appGroup)
private var logsPrivateData = false private var logsPrivateData = false
var availableTunnelLogs: () -> [LogEntry] = { var availableTunnelLogs: () async -> [LogEntry] = {
await Task.detached {
PassepartoutConfiguration.shared.availableLogs(at: BundleConfiguration.urlForTunnelLog) PassepartoutConfiguration.shared.availableLogs(at: BundleConfiguration.urlForTunnelLog)
.sorted { .sorted {
$0.key > $1.key $0.key > $1.key
@ -58,6 +59,7 @@ struct DiagnosticsView: View {
.map { .map {
LogEntry(date: $0, url: $1) LogEntry(date: $0, url: $1)
} }
}.value
} }
@State @State
@ -81,8 +83,8 @@ struct DiagnosticsView: View {
reportIssueSection reportIssueSection
} }
} }
.onLoad { .task {
tunnelLogs = availableTunnelLogs() tunnelLogs = await availableTunnelLogs()
} }
.themeForm() .themeForm()
.navigationTitle(Strings.Views.Diagnostics.title) .navigationTitle(Strings.Views.Diagnostics.title)