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

Commit

Permalink
Add migration for the first window if the active window is not found.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T committed Dec 7, 2023
1 parent b4ce589 commit b57ea22
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Sources/Brave/Migration/Migration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ public class Migration {

public static func migrateLostTabsActiveWindow() {
if UIApplication.shared.supportsMultipleScenes { return }
if Preferences.Migration.lostTabsWindowIDMigrationOne.value { return }
if Preferences.Migration.lostTabsWindowIDMigration.value { return }

let sessionWindows = SessionWindow.all()
guard let activeWindow = sessionWindows.first(where: { $0.isSelected }) else {
var sessionWindows = SessionWindow.all()
var activeWindow = sessionWindows.first(where: { $0.isSelected })
if activeWindow == nil {
activeWindow = sessionWindows.removeFirst()
}

guard let activeWindow = activeWindow else {
Preferences.Migration.lostTabsWindowIDMigration.value = true
return
}

Expand Down Expand Up @@ -93,7 +99,7 @@ public class Migration {
}
}

Preferences.Migration.lostTabsWindowIDMigrationOne.value = true
Preferences.Migration.lostTabsWindowIDMigration.value = true
}

public static func postCoreDataInitMigrations() {
Expand Down Expand Up @@ -158,8 +164,8 @@ fileprivate extension Preferences {
key: "migration.ad-block-and-tracking-protection-shield-level-completed", default: false
)

static let lostTabsWindowIDMigrationOne = Option<Bool>(
key: "migration.lost-tabs-window-id-one",
static let lostTabsWindowIDMigration = Option<Bool>(
key: "migration.lost-tabs-window-id-two",
default: !UIApplication.shared.supportsMultipleScenes
)
}
Expand Down

0 comments on commit b57ea22

Please sign in to comment.