Skip to content

Commit

Permalink
More efficient menu bar hidden check
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbaird committed Jul 4, 2024
1 parent 5514bad commit 2f592fb
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions Ice/MenuBar/MenuBarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,24 @@ final class MenuBarManager: ObservableObject {
}
.store(in: &c)

Timer.publish(every: 1, on: .main, in: .default)
.autoconnect()
.sink { [weak self] _ in
guard
let self,
let isMenuBarHidden = Defaults.globalDomain["_HIHideMenuBar"] as? Bool
else {
return
if
let hiddenSection = section(withName: .alwaysHidden),
let window = hiddenSection.controlItem.window
{
window.publisher(for: \.frame)
.map { $0.origin.y }
.removeDuplicates()
.sink { [weak self] _ in
guard
let self,
let isMenuBarHidden = Defaults.globalDomain["_HIHideMenuBar"] as? Bool
else {
return
}
isMenuBarHiddenBySystemUserDefaults = isMenuBarHidden
}
isMenuBarHiddenBySystemUserDefaults = isMenuBarHidden
}
.store(in: &c)
.store(in: &c)
}

// handle focusedApp rehide strategy
NSWorkspace.shared.publisher(for: \.frontmostApplication)
Expand Down

0 comments on commit 2f592fb

Please sign in to comment.