Skip to content

Commit 9d4a82f

Browse files
committed
Remove app icon badge
1 parent afaaf0a commit 9d4a82f

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

apple/InlineIOS/AppDelegate.swift

-2
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,13 @@ class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDele
4848
Task {
4949
// Mark offline
5050
try? await DataManager.shared.updateStatus(online: false)
51-
UnreadManager.shared.updateAppIconBadge()
5251
}
5352
}
5453

5554
private func applicationDidBecomeActive(_ notification: Notification) {
5655
Task {
5756
// Mark online
5857
try? await DataManager.shared.updateStatus(online: true)
59-
UnreadManager.shared.updateAppIconBadge()
6058
}
6159
}
6260

apple/InlineKit/Sources/InlineKit/ViewModels/UnreadManager.swift

+2-31
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import GRDB
33
import Logger
44

55
#if os(iOS)
6-
import UIKit
6+
import UIKit
77
#else
8-
import AppKit
8+
import AppKit
99
#endif
1010

1111
public final class UnreadManager: Sendable {
@@ -52,34 +52,5 @@ public final class UnreadManager: Sendable {
5252
Task {
5353
try? await apiClient.readMessages(peerId: peerId, maxId: nil)
5454
}
55-
56-
updateAppIconBadge()
57-
}
58-
59-
public func updateAppIconBadge() {
60-
Task {
61-
do {
62-
let unreadChatsCount = try await AppDatabase.shared.reader.read { db in
63-
try Dialog
64-
.filter(Column("archived") == false)
65-
.filter(Column("unreadCount") > 0)
66-
// Only count private chats by checking peerUserId is not null
67-
.filter(Column("peerUserId") != nil)
68-
.fetchCount(db)
69-
}
70-
71-
#if os(iOS)
72-
DispatchQueue.main.async {
73-
UIApplication.shared.applicationIconBadgeNumber = unreadChatsCount
74-
}
75-
// #elseif os(macOS)
76-
// DispatchQueue.main.async {
77-
// NSApplication.shared.dockTile.badgeLabel = unreadChatsCount > 0 ? "\(unreadChatsCount)" : ""
78-
// }
79-
#endif
80-
} catch {
81-
log.error("Failed to update app badge: \(error)")
82-
}
83-
}
8455
}
8556
}

0 commit comments

Comments
 (0)