From 192c6ca9369d1abd14ea3e88c5424cc481e9afb0 Mon Sep 17 00:00:00 2001 From: Jordan Baird Date: Sat, 6 Jul 2024 14:52:19 -0600 Subject: [PATCH] Fix for overlay panels not appearing immediately --- .../MenuBarOverlayPanel.swift | 37 +++++-------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/Ice/MenuBarAppearance/MenuBarOverlayPanel.swift b/Ice/MenuBarAppearance/MenuBarOverlayPanel.swift index 073518a0..d982d7fc 100644 --- a/Ice/MenuBarAppearance/MenuBarOverlayPanel.swift +++ b/Ice/MenuBarAppearance/MenuBarOverlayPanel.swift @@ -54,11 +54,6 @@ class MenuBarOverlayPanel: NSPanel { private var cancellables = Set() - /// Callbacks to perform after the panel is updated. - /// - /// - Note: The callbacks are removed after each update. - private var updateCallbacks = [() -> Void]() - /// The context that manages panel update tasks. private let updateTaskContext = UpdateTaskContext() @@ -71,12 +66,12 @@ class MenuBarOverlayPanel: NSPanel { /// A Boolean value that indicates whether the panel needs to be shown. @Published var needsShow = false - /// Flags representing the components of the panel currently in need of an update. - @Published private(set) var updateFlags = Set() - /// A Boolean value that indicates whether the user is dragging a menu bar item. @Published var isDraggingMenuBarItem = false + /// Flags representing the components of the panel currently in need of an update. + @Published private(set) var updateFlags = Set() + /// The frame of the application menu. @Published private(set) var applicationMenuFrame: CGRect? @@ -204,16 +199,9 @@ class MenuBarOverlayPanel: NSPanel { guard let self, !flags.isEmpty else { return } - defer { - Task { - // must be run async, or this will not remove the flags - self.updateFlags.removeAll() - } - let updateCallbacks = self.updateCallbacks - self.updateCallbacks.removeAll() - for callback in updateCallbacks { - callback() - } + Task { + // must be run async, or this will not remove the flags + self.updateFlags.removeAll() } let windows = WindowInfo.getOnScreenWindows() guard let owningDisplay = self.validate(for: .updates, with: windows) else { @@ -332,16 +320,9 @@ class MenuBarOverlayPanel: NSPanel { orderFrontRegardless() updateFlags = [.applicationMenuFrame, .desktopWallpaper] - updateCallbacks.append { [weak self, weak appState] in - guard - let self, - let appState - else { - return - } - if !appState.menuBarManager.isMenuBarHiddenBySystem { - animator().alphaValue = 1 - } + + if !appState.menuBarManager.isMenuBarHiddenBySystem { + animator().alphaValue = 1 } }