From 2c6c8c0281de3cc96c762746623f39ea2951a84a Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 29 Mar 2024 10:25:20 +0800 Subject: [PATCH] Better handling of case where an item is deleted then opened from push notification --- .../WebReader/WebReaderLoadingContainer.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderLoadingContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderLoadingContainer.swift index bdc018795..b8f068c71 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderLoadingContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderLoadingContainer.swift @@ -18,6 +18,7 @@ import Views guard let objectID = try? await dataService.loadItemContentUsingRequestID(username: username, requestID: requestID) else { + errorMessage = "Item is no longer available" return } item = dataService.viewContext.object(with: objectID) as? Models.LibraryItem @@ -71,7 +72,19 @@ public struct WebReaderLoadingContainer: View { .onAppear { viewModel.trackReadEvent() } } } else if let errorMessage = viewModel.errorMessage { - Text(errorMessage) + NavigationView { + VStack(spacing: 15) { + Text(errorMessage) + Button(action: { + dismiss() + }, label: { + Text("Dismiss") + }) + } + } +#if os(iOS) + .navigationViewStyle(.stack) +#endif } else { ProgressView() .task {