diff options
-rw-r--r-- | Firestore/Source/Remote/FSTRemoteStore.m | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Firestore/Source/Remote/FSTRemoteStore.m b/Firestore/Source/Remote/FSTRemoteStore.m index f7c3e57..063e487 100644 --- a/Firestore/Source/Remote/FSTRemoteStore.m +++ b/Firestore/Source/Remote/FSTRemoteStore.m @@ -110,6 +110,9 @@ static const int kOnlineAttemptsBeforeFailure = 2; /** A count of consecutive failures to open the stream. */ @property(nonatomic, assign) int watchStreamFailures; +/** Whether the client should fire offline warning. */ +@property(nonatomic, assign) BOOL shouldWarnOffline; + #pragma mark Write Stream // The writeStream is null when the network is disabled. The non-null check is performed by // isNetworkEnabled. @@ -146,6 +149,7 @@ static const int kOnlineAttemptsBeforeFailure = 2; _lastBatchSeen = kFSTBatchIDUnknown; _watchStreamOnlineState = FSTOnlineStateUnknown; + _shouldWarnOffline = YES; _pendingWrites = [NSMutableArray array]; } return self; @@ -157,6 +161,7 @@ static const int kOnlineAttemptsBeforeFailure = 2; } - (void)setOnlineStateToHealthy { + self.shouldWarnOffline = NO; [self updateAndNotifyAboutOnlineState:FSTOnlineStateHealthy]; } @@ -179,6 +184,10 @@ static const int kOnlineAttemptsBeforeFailure = 2; } else { self.watchStreamFailures++; if (self.watchStreamFailures >= kOnlineAttemptsBeforeFailure) { + if (self.shouldWarnOffline) { + FSTWarn(@"Could not reach Firestore backend."); + self.shouldWarnOffline = NO; + } [self updateAndNotifyAboutOnlineState:FSTOnlineStateFailed]; } } |