fix: address all PR review comments
- HTTPClient: replace isRefreshing bool with shared Task to safely coalesce concurrent 401 refresh attempts; surface JSON serialization error instead of silently dropping request body - AuthService.logout: always clear Keychain tokens via defer, even when refresh token is absent, preventing stale access token - NotificationsAPIService: remove updateAppBadge (UIKit call moved to @MainActor NotificationsViewModel); drop unused UIKit import - NotificationsViewModel: guard startPolling() against duplicate tasks; update badge directly on @MainActor instead of hopping to actor - VerifyEmailView: replace Timer (never invalidated) with async Task cancelled in .onDisappear - NotificationsView: use Text(date, style: .relative) — auto-updates without custom formatter; remove duplicate Date extension - SettingsView: handle logoutAll errors explicitly with alert instead of silently proceeding with local logout - MaydayLiveActivity/Info.plist: add NSExtensionPrincipalClass so the widget extension is discoverable by the system - Live Activity widget: replace frozen duration(from:) with Text(date, style: .timer); replace frozen relativeFormatted with Text(date, style: .relative); localize status badge to Russian Co-authored-by: robonen <26167508+robonen@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
@MainActor
|
||||
class NotificationsViewModel: ObservableObject {
|
||||
@@ -70,8 +71,8 @@ class NotificationsViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
func startPolling() {
|
||||
// Polling always reloads page 1 to pick up new notifications.
|
||||
// Users who have scrolled to older pages will have the list reset on each interval.
|
||||
// Guard against starting a second polling loop if already running.
|
||||
guard pollingTask == nil else { return }
|
||||
pollingTask = Task {
|
||||
while !Task.isCancelled {
|
||||
try? await Task.sleep(for: .seconds(30))
|
||||
@@ -88,8 +89,6 @@ class NotificationsViewModel: ObservableObject {
|
||||
|
||||
private func updateBadge() {
|
||||
let unreadCount = notifications.filter { !$0.isRead }.count
|
||||
Task {
|
||||
await service.updateAppBadge(unreadCount)
|
||||
}
|
||||
UIApplication.shared.applicationIconBadgeNumber = unreadCount
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user