Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Fix #7832: Restored but unopened tabs not added to Recently Closed Tabs #7848

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Sources/Brave/Frontend/Browser/TabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -1144,7 +1143,7 @@ class TabManager: NSObject {
return SavedRecentlyClosed(
url: fetchedTabURL,
title: tab.displayTitle,
interactionState: interactionState,
interactionState: tab.webView?.sessionData,
order: -1)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Data/models/RecentlyClosed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down