lint more

This commit is contained in:
Hailey
2024-07-10 17:50:27 -07:00
parent 19da52f1c7
commit b37cdb135b
+9 -9
View File
@@ -13,43 +13,43 @@ class NotificationService: UNNotificationServiceExtension {
contentHandler(request.content) contentHandler(request.content)
return return
} }
if reason == "chat-message" { if reason == "chat-message" {
mutateWithChatMessage(bestAttempt) mutateWithChatMessage(bestAttempt)
} else { } else {
mutateWithBadge(bestAttempt) mutateWithBadge(bestAttempt)
} }
contentHandler(bestAttempt) contentHandler(bestAttempt)
} }
override func serviceExtensionTimeWillExpire() { override func serviceExtensionTimeWillExpire() {
// If for some reason the alloted time expires, we don't actually want to display a notification // If for some reason the alloted time expires, we don't actually want to display a notification
} }
func createCopy(_ content: UNNotificationContent) -> UNMutableNotificationContent? { func createCopy(_ content: UNNotificationContent) -> UNMutableNotificationContent? {
return content.mutableCopy() as? UNMutableNotificationContent return content.mutableCopy() as? UNMutableNotificationContent
} }
func mutateWithBadge(_ content: UNMutableNotificationContent) { func mutateWithBadge(_ content: UNMutableNotificationContent) {
var count = prefs?.integer(forKey: "badgeCount") ?? 0 var count = prefs?.integer(forKey: "badgeCount") ?? 0
count += 1 count += 1
// Set the new badge number for the notification, then store that value for using later // Set the new badge number for the notification, then store that value for using later
content.badge = NSNumber(value: count) content.badge = NSNumber(value: count)
prefs?.setValue(count, forKey: "badgeCount") prefs?.setValue(count, forKey: "badgeCount")
} }
func mutateWithChatMessage(_ content: UNMutableNotificationContent) { func mutateWithChatMessage(_ content: UNMutableNotificationContent) {
if self.prefs?.bool(forKey: "playSoundChat") == true { if self.prefs?.bool(forKey: "playSoundChat") == true {
mutateWithDmSound(content) mutateWithDmSound(content)
} }
} }
func mutateWithDefaultSound(_ content: UNMutableNotificationContent) { func mutateWithDefaultSound(_ content: UNMutableNotificationContent) {
content.sound = UNNotificationSound.default content.sound = UNNotificationSound.default
} }
func mutateWithDmSound(_ content: UNMutableNotificationContent) { func mutateWithDmSound(_ content: UNMutableNotificationContent) {
content.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "dm.aiff")) content.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "dm.aiff"))
} }