Avoid race and duplication conditions between local and remote notifications (#848)

* added timestamp control of the local notification

* improved the code, and implemented the solution, just needs some testing

* sdk bump

* UserPreference init with initialValue instead of defaultValue

* pr suggestions

* changelog

* notifications sliding sync view added
This commit is contained in:
Mauro
2023-05-03 16:28:07 +02:00
committed by GitHub
parent 60c2692a26
commit 95492d7e10
15 changed files with 251 additions and 108 deletions
@@ -84,7 +84,7 @@ class AppCoordinator: AppCoordinatorProtocol {
wipeUserData(includingSettings: true)
}
ServiceLocator.shared.settings.lastVersionLaunched = currentVersion.description
setupStateMachine()
observeApplicationState()
@@ -18,7 +18,7 @@ import Foundation
import SwiftUI
/// Store Element specific app settings.
final class AppSettings: ObservableObject {
final class AppSettings {
private enum UserDefaultsKeys: String {
case lastVersionLaunched
case seenInvites
@@ -69,6 +69,8 @@ final class AppSettings: ObservableObject {
/// deleted between runs so should clear data in the shared container and keychain.
@UserPreference(key: UserDefaultsKeys.lastVersionLaunched, storageType: .userDefaults(store))
var lastVersionLaunched: String?
let lastLaunchDate = Date()
/// The Set of room identifiers of invites that the user already saw in the invites list.
/// This Set is being used to implement badges for unread invites.
@@ -146,11 +148,15 @@ final class AppSettings: ObservableObject {
/// Tag describing which set of device specific rules a pusher executes.
@UserPreference(key: UserDefaultsKeys.pusherProfileTag, storageType: .userDefaults(store))
var pusherProfileTag: String?
/// A set of all the notification identifiers that have been served so far, it's reset every time the app is launched
@UserPreference(key: SharedUserDefaultsKeys.servedNotificationIdentifiers, initialValue: [], storageType: .userDefaults(store))
var servedNotificationIdentifiers: Set<String>
// MARK: - Other
let permalinkBaseURL = URL(staticString: "https://matrix.to")
// MARK: - Feature Flags
// MARK: Start Chat