Skip to content

Commit

Permalink
Receive several publishers on main queue
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbaird committed Sep 28, 2024
1 parent 8f003e6 commit 19087a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Ice/Main/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ final class AppState: ObservableObject {
.delay(for: 0.1, scheduler: DispatchQueue.main)
.mapToVoid()
)
.receive(on: DispatchQueue.main)
.sink { [weak self] _ in
guard let self else {
return
Expand Down
4 changes: 4 additions & 0 deletions Ice/MenuBar/MenuBarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ final class MenuBarManager: ObservableObject {
var c = Set<AnyCancellable>()

NSApp.publisher(for: \.currentSystemPresentationOptions)
.receive(on: DispatchQueue.main)
.sink { [weak self] options in
guard let self else {
return
Expand All @@ -112,6 +113,7 @@ final class MenuBarManager: ObservableObject {
window.publisher(for: \.frame)
.map { $0.origin.y }
.removeDuplicates()
.receive(on: DispatchQueue.main)
.sink { [weak self] _ in
guard
let self,
Expand All @@ -126,6 +128,7 @@ final class MenuBarManager: ObservableObject {

// Handle the `focusedApp` rehide strategy.
NSWorkspace.shared.publisher(for: \.frontmostApplication)
.receive(on: DispatchQueue.main)
.sink { [weak self] _ in
if
let self,
Expand All @@ -150,6 +153,7 @@ final class MenuBarManager: ObservableObject {
settingsWindow.publisher(for: \.isVisible),
iceBarPanel.publisher(for: \.isVisible)
)
.receive(on: DispatchQueue.main)
.sink { [weak self] settingsIsVisible, iceBarIsVisible in
guard let self else {
return
Expand Down

0 comments on commit 19087a2

Please sign in to comment.