From 7d3e1e879f70894c23e36e8d2f97ae23ed6269d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 20 Feb 2025 22:27:43 +0800 Subject: [PATCH] Fix showing deprecated warnings without link --- .../Views/Dashboard/DashboardView.swift | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/ApplicationLibrary/Views/Dashboard/DashboardView.swift b/ApplicationLibrary/Views/Dashboard/DashboardView.swift index 1c5cebc..628c2a7 100644 --- a/ApplicationLibrary/Views/Dashboard/DashboardView.swift +++ b/ApplicationLibrary/Views/Dashboard/DashboardView.swift @@ -141,23 +141,36 @@ public struct DashboardView: View { private func loopShowDeprecateNotes(_ reports: any LibboxDeprecatedNoteIteratorProtocol) { if reports.hasNext() { let report = reports.next()! - alert = Alert( - title: Text("Deprecated Warning"), - message: Text(report.message()), - primaryButton: .default(Text("Documentation")) { - openURL(URL(string: report.migrationLink)!) - Task.detached { - try await Task.sleep(nanoseconds: 300 * MSEC_PER_SEC) - await loopShowDeprecateNotes(reports) + if report.migrationLink.isEmpty { + alert = Alert( + title: Text("Deprecated Warning"), + message: Text(report.message()), + dismissButton: .cancel(Text("Ok")) { + Task.detached { + try await Task.sleep(nanoseconds: 300 * MSEC_PER_SEC) + await loopShowDeprecateNotes(reports) + } } - }, - secondaryButton: .cancel(Text("Ok")) { - Task.detached { - try await Task.sleep(nanoseconds: 300 * MSEC_PER_SEC) - await loopShowDeprecateNotes(reports) + ) + } else { + alert = Alert( + title: Text("Deprecated Warning"), + message: Text(report.message()), + primaryButton: .default(Text("Documentation")) { + openURL(URL(string: report.migrationLink)!) + Task.detached { + try await Task.sleep(nanoseconds: 300 * MSEC_PER_SEC) + await loopShowDeprecateNotes(reports) + } + }, + secondaryButton: .cancel(Text("Ok")) { + Task.detached { + try await Task.sleep(nanoseconds: 300 * MSEC_PER_SEC) + await loopShowDeprecateNotes(reports) + } } - } - ) + ) + } } }