Calls: убран "Start New Call", добавлены аватарки и исправлена область нажатия строки

This commit is contained in:
2026-03-31 19:32:11 +05:00
parent 464fae37a9
commit 0470b306a9
8 changed files with 85 additions and 66 deletions

View File

@@ -12,6 +12,9 @@ final class NotificationService: UNNotificationServiceExtension {
private static let appGroupID = "group.com.rosetta.dev"
private static let badgeKey = "app_badge_count"
private static let processedIdsKey = "nse_processed_message_ids"
/// Max dedup entries kept in App Group NSE has tight memory limits.
private static let maxProcessedIds = 100
/// Android parity: multiple key names for sender public key extraction.
/// Server sends `dialog` field (was `from`). Both kept for backward compat.
@@ -132,11 +135,30 @@ final class NotificationService: UNNotificationServiceExtension {
return
}
// 4. Increment badge count only for non-muted chats.
let current = shared.integer(forKey: Self.badgeKey)
let newBadge = current + 1
shared.set(newBadge, forKey: Self.badgeKey)
content.badge = NSNumber(value: newBadge)
// 3.5 Dedup: skip badge increment if we already processed this push.
// Protects against duplicate FCM delivery (rare, but server dedup window is ~10s).
let messageId = content.userInfo["message_id"] as? String
?? content.userInfo["messageId"] as? String
?? request.identifier
var processedIds = shared.stringArray(forKey: Self.processedIdsKey) ?? []
if processedIds.contains(messageId) {
// Already counted show notification but don't inflate badge.
let currentBadge = shared.integer(forKey: Self.badgeKey)
content.badge = NSNumber(value: currentBadge)
} else {
// 4. Increment badge count only for non-muted, non-duplicate chats.
let current = shared.integer(forKey: Self.badgeKey)
let newBadge = current + 1
shared.set(newBadge, forKey: Self.badgeKey)
content.badge = NSNumber(value: newBadge)
// Track this message ID. Evict oldest if over limit.
processedIds.append(messageId)
if processedIds.count > Self.maxProcessedIds {
processedIds = Array(processedIds.suffix(Self.maxProcessedIds))
}
shared.set(processedIds, forKey: Self.processedIdsKey)
}
}
// 5. Normalize sender_public_key in userInfo for tap navigation.