diff --git a/Sources/Brave/Frontend/Browser/TabManager.swift b/Sources/Brave/Frontend/Browser/TabManager.swift index 67ce8e422d4..f5ec0ea5452 100644 --- a/Sources/Brave/Frontend/Browser/TabManager.swift +++ b/Sources/Brave/Frontend/Browser/TabManager.swift @@ -1127,13 +1127,12 @@ class TabManager: NSObject { } // NTP should not be passed as Recently Closed item - guard let tabUrl = tab.url, - let interactionState = tab.webView?.sessionData else { return nil } - - if InternalURL(tabUrl)?.isAboutHomeURL == true { + let recentlyClosedURL = tab.url ?? SessionTab.from(tabId: tab.id)?.url + + guard let tabUrl = recentlyClosedURL, tabUrl.isWebPage() else { return nil } - + // Convert any internal URLs to their real URL for the Recently Closed item var fetchedTabURL = tabUrl if let url = InternalURL(fetchedTabURL), @@ -1144,7 +1143,7 @@ class TabManager: NSObject { return SavedRecentlyClosed( url: fetchedTabURL, title: tab.displayTitle, - interactionState: interactionState, + interactionState: tab.webView?.sessionData, order: -1) } } diff --git a/Sources/Data/models/RecentlyClosed.swift b/Sources/Data/models/RecentlyClosed.swift index 24e1eb685e2..be1c71709b1 100644 --- a/Sources/Data/models/RecentlyClosed.swift +++ b/Sources/Data/models/RecentlyClosed.swift @@ -12,10 +12,10 @@ public struct SavedRecentlyClosed { public let url: String public let title: String public let dateAdded: Date - public let interactionState: Data + public let interactionState: Data? public let index: Int32 - public init(url: URL, title: String, dateAdded: Date = .now, interactionState: Data, order: Int32) { + public init(url: URL, title: String, dateAdded: Date = .now, interactionState: Data?, order: Int32) { self.url = url.absoluteString self.title = title self.dateAdded = dateAdded