Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions airsync-mac/Core/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class AppState: ObservableObject {
self.alwaysOpenWindow = UserDefaults.standard.bool(forKey: "alwaysOpenWindow")
self.notificationSound = UserDefaults.standard.string(forKey: "notificationSound") ?? "default"
self.dismissNotif = UserDefaults.standard.bool(forKey: "dismissNotif")
self.silenceAllNotifications = UserDefaults.standard.bool(forKey: "silenceAllNotifications")

self.autoAcceptQuickShare = UserDefaults.standard.bool(forKey: "autoAcceptQuickShare")
self.quickShareEnabled = UserDefaults.standard.object(forKey: "quickShareEnabled") == nil ? true : UserDefaults.standard.bool(forKey: "quickShareEnabled")
Expand Down Expand Up @@ -308,6 +309,16 @@ class AppState: ObservableObject {
}
}

@Published var silenceAllNotifications: Bool {
didSet {
UserDefaults.standard.set(silenceAllNotifications, forKey: "silenceAllNotifications")
if silenceAllNotifications {
UNUserNotificationCenter.current().removeAllDeliveredNotifications()
UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
}
}
}

@Published var callNotificationMode: CallNotificationMode = .popup {
didSet {
UserDefaults.standard.set(callNotificationMode.rawValue, forKey: "callNotificationMode")
Expand Down Expand Up @@ -571,6 +582,10 @@ class AppState: ObservableObject {
}

private func postCallSystemNotification(_ callEvent: CallEvent) {
if silenceAllNotifications {
return
}

let center = UNUserNotificationCenter.current()
let content = UNMutableNotificationContent()

Expand Down Expand Up @@ -786,6 +801,10 @@ class AppState: ObservableObject {
extraActions: [UNNotificationAction] = [],
extraUserInfo: [String: Any] = [:]
) {
if silenceAllNotifications {
return
}

let center = UNUserNotificationCenter.current()
let content = UNMutableNotificationContent()
content.title = "\(appName) - \(title)"
Expand Down
10 changes: 10 additions & 0 deletions airsync-mac/Screens/MenubarView/MenubarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ struct MenubarView: View {
)
}

GlassButtonView(
label: appState.silenceAllNotifications ? "Disable DND" : "Enable DND",
systemImage: appState.silenceAllNotifications ? "bell.slash.fill" : "bell.badge",
iconOnly: true,
circleSize: toolButtonSize
) {
appState.silenceAllNotifications.toggle()
}
.help(appState.silenceAllNotifications ? "Do Not Disturb is ON" : "Turn on Do Not Disturb")

GlassButtonView(
label: "Quit",
systemImage: "power",
Expand Down