Skip to content

Commit

Permalink
fix: Always give same ID for window macOS (#1507)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeWeidmann authored Aug 13, 2024
2 parents d0f5ba8 + fafe4d2 commit 8bd83ec
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Mail/Commands/CustomCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct CustomCommands: Commands {
if #available(iOS 16.0, *) {
NewMessageCommand(mailboxManager: mainViewState?.mailboxManager)

NewWindowCommand(rootViewState: rootViewState)
NewWindowCommand()
}
}

Expand Down
6 changes: 2 additions & 4 deletions Mail/Commands/NewWindowCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@ struct NewWindowCommand: View {

@Environment(\.openWindow) private var openWindow

let rootViewState: RootViewState

var body: some View {
Button(MailResourcesStrings.Localizable.buttonNewWindow) {
newWindow()
}
.keyboardShortcut("n", modifiers: [.option, .command])
}

@MainActor func newWindow() {
func newWindow() {
matomo.track(eventWithCategory: .menuAction, name: "newWindow")
openWindow(id: DesktopWindowIdentifier.mainWindowIdentifier(currentViewState: rootViewState))
openWindow(id: DesktopWindowIdentifier.mainWindowIdentifier)
}
}
2 changes: 1 addition & 1 deletion Mail/UserAccountScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct UserAccountScene: Scene {
@StateObject private var rootViewState = RootViewState()

var body: some Scene {
WindowGroup(id: DesktopWindowIdentifier.mainWindowIdentifier(currentViewState: rootViewState)) {
WindowGroup(id: DesktopWindowIdentifier.mainWindowIdentifier) {
RootView()
.standardWindow()
.environmentObject(rootViewState)
Expand Down
10 changes: 1 addition & 9 deletions MailCore/Utils/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,7 @@ public enum DesktopWindowIdentifier {
public static let settingsWindowIdentifier = "settings"
public static let composeWindowIdentifier = "compose"
public static let threadWindowIdentifier = "thread"

@MainActor
public static func mainWindowIdentifier(currentViewState: RootViewState) -> String {
if case .mainView(let mainViewState) = currentViewState.state {
return "Main-\(mainViewState.mailboxManager.mailbox.objectId)"
} else {
return "Main"
}
}
public static let mainWindowIdentifier = "main"
}

public struct URLConstants {
Expand Down

0 comments on commit 8bd83ec

Please sign in to comment.