diff --git a/AmplifyPlugins/API/AWSAPICategoryPlugin/Reachability/NetworkReachabilityNotifier.swift b/AmplifyPlugins/API/AWSAPICategoryPlugin/Reachability/NetworkReachabilityNotifier.swift index 4877bb4401..a45bd72766 100644 --- a/AmplifyPlugins/API/AWSAPICategoryPlugin/Reachability/NetworkReachabilityNotifier.swift +++ b/AmplifyPlugins/API/AWSAPICategoryPlugin/Reachability/NetworkReachabilityNotifier.swift @@ -15,6 +15,7 @@ class NetworkReachabilityNotifier { private var reachability: NetworkReachabilityProviding? private var allowsCellularAccess = true + // This is a CurrentValueSubject. Please do not change this unless you talk to wooj2@ or palpatim@ before changing this. let reachabilityPublisher = CurrentValueSubject(ReachabilityUpdate(isOnline: false)) var publisher: AnyPublisher { return reachabilityPublisher.eraseToAnyPublisher() diff --git a/AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Sync/MutationSync/OutgoingMutationQueue/MutationRetryNotifier.swift b/AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Sync/MutationSync/OutgoingMutationQueue/MutationRetryNotifier.swift index 8c124b6afb..721775680d 100644 --- a/AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Sync/MutationSync/OutgoingMutationQueue/MutationRetryNotifier.swift +++ b/AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Sync/MutationSync/OutgoingMutationQueue/MutationRetryNotifier.swift @@ -22,10 +22,10 @@ final class MutationRetryNotifier { retryMutationCallback: @escaping BasicClosure) { self.retryMutationCallback = retryMutationCallback - networkReachabilityPublisher?.subscribe(self) - let deadline = DispatchTime.now() + advice.retryInterval scheduleTimer(at: deadline) + + networkReachabilityPublisher?.dropFirst().subscribe(self) } deinit { diff --git a/AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginTests/Sync/MutationQueue/SyncMutationToCloudOperationTests.swift b/AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginTests/Sync/MutationQueue/SyncMutationToCloudOperationTests.swift index 437f5b3cbb..c4497fc31d 100644 --- a/AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginTests/Sync/MutationQueue/SyncMutationToCloudOperationTests.swift +++ b/AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginTests/Sync/MutationQueue/SyncMutationToCloudOperationTests.swift @@ -20,13 +20,13 @@ class SyncMutationToCloudOperationTests: XCTestCase { let secondsInADay = 60 * 60 * 24 var mockAPIPlugin: MockAPICategoryPlugin! - var reachabilityPublisher: PassthroughSubject! + var reachabilityPublisher: CurrentValueSubject! var publisher: AnyPublisher { return reachabilityPublisher.eraseToAnyPublisher() } override func setUp() { - reachabilityPublisher = PassthroughSubject() + reachabilityPublisher = CurrentValueSubject(ReachabilityUpdate(isOnline: false)) tryOrFail { try setUpWithAPI() }