aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Remote
diff options
context:
space:
mode:
authorGravatar zxu <zxu@google.com>2017-12-07 09:05:02 -0500
committerGravatar GitHub <noreply@github.com>2017-12-07 09:05:02 -0500
commit4daf75d37262287e4040b346bb1f458ef905184d (patch)
treed55a361d53f03df2d4dafeb90d2f79699c33a189 /Firestore/Source/Remote
parent32bdc38400258b24edb37990cc8cba057a3297de (diff)
parent125cdc78c68b322d4ff06a906ed32548ade46003 (diff)
Merge pull request #514 from firebase/zxu/logoffline
Warn user if we raise with empty while not online
Diffstat (limited to 'Firestore/Source/Remote')
-rw-r--r--Firestore/Source/Remote/FSTRemoteStore.m9
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];
}
}