diff --git a/Sources/Brave/Frontend/Browser/TabManager.swift b/Sources/Brave/Frontend/Browser/TabManager.swift index 77d0fc92922d..34d77251175f 100644 --- a/Sources/Brave/Frontend/Browser/TabManager.swift +++ b/Sources/Brave/Frontend/Browser/TabManager.swift @@ -523,6 +523,7 @@ class TabManager: NSObject { if let request = request { tab.loadRequest(request) + tab.url = request.url } else if !isPopup { tab.loadRequest(PrivilegedRequest(url: TabManager.ntpInteralURL) as URLRequest) tab.url = TabManager.ntpInteralURL @@ -901,7 +902,11 @@ class TabManager: NSObject { for savedTab in savedTabs { let tabURL = savedTab.url // Provide an empty request to prevent a new tab from loading the home screen - let tab = addTab(URLRequest(url: tabURL), + let request = InternalURL.isValid(url: tabURL) ? + PrivilegedRequest(url: tabURL) as URLRequest : + URLRequest(url: tabURL) + + let tab = addTab(request, flushToDisk: false, zombie: true, id: savedTab.tabId, diff --git a/Sources/Data/models/SessionTab.swift b/Sources/Data/models/SessionTab.swift index 7fc8866d8550..94f21568e8bb 100644 --- a/Sources/Data/models/SessionTab.swift +++ b/Sources/Data/models/SessionTab.swift @@ -147,7 +147,10 @@ extension SessionTab { public static func update(tabId: UUID, interactionState: Data, title: String, url: URL) { DataController.perform { context in - guard let sessionTab = Self.from(tabId: tabId, in: context) else { return } + guard let sessionTab = Self.from(tabId: tabId, in: context) else { + Logger.module.error("Error: SessionTab.update missing managed object") + return + } sessionTab.interactionState = interactionState sessionTab.title = title sessionTab.url = url @@ -166,7 +169,7 @@ extension SessionTab { DataController.perform { context in for (index, tabId) in tabIds.enumerated() { guard let tab = Self.from(tabId: tabId, in: context) else { - Logger.module.error("Error: SessionTab missing managed object") + Logger.module.error("Error: SessionTab.updateScreenshot missing managed object") continue } tab.index = Int32(index) @@ -176,12 +179,14 @@ extension SessionTab { public static func updateAll(tabs: [(tabId: UUID, interactionState: Data, title: String, url: URL)]) { DataController.performOnMainContext { context in - for (index, tab) in tabs.enumerated() { - guard let sessionTab = Self.from(tabId: tab.tabId, in: context) else { return } + for tab in tabs { + guard let sessionTab = Self.from(tabId: tab.tabId, in: context) else { + Logger.module.error("Error: SessionTab.updateAll missing managed object") + continue + } sessionTab.interactionState = tab.interactionState sessionTab.title = tab.title sessionTab.url = tab.url - sessionTab.index = Int32(index) } do {