Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Firestore/Example/Tests/Core/FSTEventManagerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ - (void)testWillForwardOnlineStateChanges {
FSTQueryListener *fakeListener = OCMClassMock([FSTQueryListener class]);
NSMutableArray *events = [NSMutableArray array];
OCMStub([fakeListener query]).andReturn(query);
OCMStub([fakeListener clientDidChangeOnlineState:FSTOnlineStateUnknown])
OCMStub([fakeListener applyChangedOnlineState:FSTOnlineStateUnknown])
.andDo(^(NSInvocation *invocation) {
[events addObject:@(FSTOnlineStateUnknown)];
});
OCMStub([fakeListener clientDidChangeOnlineState:FSTOnlineStateHealthy])
OCMStub([fakeListener applyChangedOnlineState:FSTOnlineStateHealthy])
.andDo(^(NSInvocation *invocation) {
[events addObject:@(FSTOnlineStateHealthy)];
});
Expand All @@ -154,7 +154,7 @@ - (void)testWillForwardOnlineStateChanges {

[eventManager addListener:fakeListener];
XCTAssertEqualObjects(events, @[ @(FSTOnlineStateUnknown) ]);
[eventManager watchStreamDidChangeOnlineState:FSTOnlineStateHealthy];
[eventManager applyChangedOnlineState:FSTOnlineStateHealthy];
XCTAssertEqualObjects(events, (@[ @(FSTOnlineStateUnknown), @(FSTOnlineStateHealthy) ]));
}

Expand Down
28 changes: 14 additions & 14 deletions Firestore/Example/Tests/Core/FSTQueryListenerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,10 @@ - (void)testWillWaitForSyncIfOnline {
[FSTTargetChange changeWithDocuments:@[ doc1, doc2 ]
currentStatusUpdate:FSTCurrentStatusUpdateMarkCurrent]);

[listener clientDidChangeOnlineState:FSTOnlineStateHealthy]; // no event
[listener applyChangedOnlineState:FSTOnlineStateHealthy]; // no event
[listener queryDidChangeViewSnapshot:snap1];
[listener clientDidChangeOnlineState:FSTOnlineStateUnknown];
[listener clientDidChangeOnlineState:FSTOnlineStateHealthy];
[listener applyChangedOnlineState:FSTOnlineStateUnknown];
[listener applyChangedOnlineState:FSTOnlineStateHealthy];
[listener queryDidChangeViewSnapshot:snap2];
[listener queryDidChangeViewSnapshot:snap3];

Expand Down Expand Up @@ -379,12 +379,12 @@ - (void)testWillRaiseInitialEventWhenGoingOffline {
FSTViewSnapshot *snap1 = FSTTestApplyChanges(view, @[ doc1 ], nil);
FSTViewSnapshot *snap2 = FSTTestApplyChanges(view, @[ doc2 ], nil);

[listener clientDidChangeOnlineState:FSTOnlineStateHealthy]; // no event
[listener queryDidChangeViewSnapshot:snap1]; // no event
[listener clientDidChangeOnlineState:FSTOnlineStateFailed]; // event
[listener clientDidChangeOnlineState:FSTOnlineStateUnknown]; // no event
[listener clientDidChangeOnlineState:FSTOnlineStateFailed]; // no event
[listener queryDidChangeViewSnapshot:snap2]; // another event
[listener applyChangedOnlineState:FSTOnlineStateHealthy]; // no event
[listener queryDidChangeViewSnapshot:snap1]; // no event
[listener applyChangedOnlineState:FSTOnlineStateFailed]; // event
[listener applyChangedOnlineState:FSTOnlineStateUnknown]; // no event
[listener applyChangedOnlineState:FSTOnlineStateFailed]; // no event
[listener queryDidChangeViewSnapshot:snap2]; // another event

FSTDocumentViewChange *change1 =
[FSTDocumentViewChange changeWithDocument:doc1 type:FSTDocumentViewChangeTypeAdded];
Expand Down Expand Up @@ -419,9 +419,9 @@ - (void)testWillRaiseInitialEventWhenGoingOfflineAndThereAreNoDocs {
FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]];
FSTViewSnapshot *snap1 = FSTTestApplyChanges(view, @[], nil);

[listener clientDidChangeOnlineState:FSTOnlineStateHealthy]; // no event
[listener queryDidChangeViewSnapshot:snap1]; // no event
[listener clientDidChangeOnlineState:FSTOnlineStateFailed]; // event
[listener applyChangedOnlineState:FSTOnlineStateHealthy]; // no event
[listener queryDidChangeViewSnapshot:snap1]; // no event
[listener applyChangedOnlineState:FSTOnlineStateFailed]; // event

FSTViewSnapshot *expectedSnap = [[FSTViewSnapshot alloc]
initWithQuery:query
Expand All @@ -445,8 +445,8 @@ - (void)testWillRaiseInitialEventWhenStartingOfflineAndThereAreNoDocs {
FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:[FSTDocumentKeySet keySet]];
FSTViewSnapshot *snap1 = FSTTestApplyChanges(view, @[], nil);

[listener clientDidChangeOnlineState:FSTOnlineStateFailed]; // no event
[listener queryDidChangeViewSnapshot:snap1]; // event
[listener applyChangedOnlineState:FSTOnlineStateFailed]; // no event
[listener queryDidChangeViewSnapshot:snap1]; // event

FSTViewSnapshot *expectedSnap = [[FSTViewSnapshot alloc]
initWithQuery:query
Expand Down
6 changes: 3 additions & 3 deletions Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ - (instancetype)initWithPersistence:(id<FSTPersistence>)persistence
return self;
}

- (void)watchStreamDidChangeOnlineState:(FSTOnlineState)onlineState {
[self.syncEngine applyOnlineStateChange:onlineState];
[self.eventManager watchStreamDidChangeOnlineState:onlineState];
- (void)applyChangedOnlineState:(FSTOnlineState)onlineState {
[self.syncEngine applyChangedOnlineState:onlineState];
[self.eventManager applyChangedOnlineState:onlineState];
}

- (void)start {
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Source/Core/FSTEventManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN

- (void)queryDidChangeViewSnapshot:(FSTViewSnapshot *)snapshot;
- (void)queryDidError:(NSError *)error;
- (void)clientDidChangeOnlineState:(FSTOnlineState)onlineState;
- (void)applyChangedOnlineState:(FSTOnlineState)onlineState;

@property(nonatomic, strong, readonly) FSTQuery *query;

Expand Down
8 changes: 4 additions & 4 deletions Firestore/Source/Core/FSTEventManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ - (void)queryDidError:(NSError *)error {
self.viewSnapshotHandler(nil, error);
}

- (void)clientDidChangeOnlineState:(FSTOnlineState)onlineState {
- (void)applyChangedOnlineState:(FSTOnlineState)onlineState {
self.onlineState = onlineState;
if (self.snapshot && !self.raisedInitialEvent &&
[self shouldRaiseInitialEventForSnapshot:self.snapshot onlineState:onlineState]) {
Expand Down Expand Up @@ -268,7 +268,7 @@ - (FSTTargetID)addListener:(FSTQueryListener *)listener {
}
[queryInfo.listeners addObject:listener];

[listener clientDidChangeOnlineState:self.onlineState];
[listener applyChangedOnlineState:self.onlineState];

if (queryInfo.viewSnapshot) {
[listener queryDidChangeViewSnapshot:queryInfo.viewSnapshot];
Expand Down Expand Up @@ -321,11 +321,11 @@ - (void)handleError:(NSError *)error forQuery:(FSTQuery *)query {
[self.queries removeObjectForKey:query];
}

- (void)watchStreamDidChangeOnlineState:(FSTOnlineState)onlineState {
- (void)applyChangedOnlineState:(FSTOnlineState)onlineState {
self.onlineState = onlineState;
for (FSTQueryListenersInfo *info in self.queries.objectEnumerator) {
for (FSTQueryListener *listener in info.listeners) {
[listener clientDidChangeOnlineState:onlineState];
[listener applyChangedOnlineState:onlineState];
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Firestore/Source/Core/FSTFirestoreClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ - (void)userDidChange:(FSTUser *)user {
[self.syncEngine userDidChange:user];
}

- (void)watchStreamDidChangeOnlineState:(FSTOnlineState)onlineState {
[self.syncEngine applyOnlineStateChange:onlineState];
[self.eventManager watchStreamDidChangeOnlineState:onlineState];
- (void)applyChangedOnlineState:(FSTOnlineState)onlineState {
[self.syncEngine applyChangedOnlineState:onlineState];
[self.eventManager applyChangedOnlineState:onlineState];
}

- (void)disableNetworkWithCompletion:(nullable FSTVoidErrorBlock)completion {
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Source/Core/FSTSyncEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)userDidChange:(FSTUser *)user;

/** Applies an FSTOnlineState change to the sync engine and notifies any views of the change. */
- (void)applyOnlineStateChange:(FSTOnlineState)onlineState;
- (void)applyChangedOnlineState:(FSTOnlineState)onlineState;

@end

Expand Down
4 changes: 2 additions & 2 deletions Firestore/Source/Core/FSTSyncEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ - (void)applyRemoteEvent:(FSTRemoteEvent *)remoteEvent {
[self emitNewSnapshotsWithChanges:changes remoteEvent:remoteEvent];
}

- (void)applyOnlineStateChange:(FSTOnlineState)onlineState {
- (void)applyChangedOnlineState:(FSTOnlineState)onlineState {
NSMutableArray<FSTViewSnapshot *> *newViewSnapshots = [NSMutableArray array];
[self.queryViewsByQuery
enumerateKeysAndObjectsUsingBlock:^(FSTQuery *query, FSTQueryView *queryView, BOOL *stop) {
FSTViewChange *viewChange = [queryView.view applyOnlineStateChange:onlineState];
FSTViewChange *viewChange = [queryView.view applyChangedOnlineState:onlineState];
FSTAssert(viewChange.limboChanges.count == 0,
@"OnlineState should not affect limbo documents.");
if (viewChange.snapshot) {
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Source/Core/FSTView.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ typedef NS_ENUM(NSInteger, FSTLimboDocumentChangeType) {
* Applies an FSTOnlineState change to the view, potentially generating an FSTViewChange if the
* view's syncState changes as a result.
*/
- (FSTViewChange *)applyOnlineStateChange:(FSTOnlineState)onlineState;
- (FSTViewChange *)applyChangedOnlineState:(FSTOnlineState)onlineState;

@end

Expand Down
2 changes: 1 addition & 1 deletion Firestore/Source/Core/FSTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ - (FSTViewChange *)applyChangesToDocuments:(FSTViewDocumentChanges *)docChanges
}
}

- (FSTViewChange *)applyOnlineStateChange:(FSTOnlineState)onlineState {
- (FSTViewChange *)applyChangedOnlineState:(FSTOnlineState)onlineState {
if (self.isCurrent && onlineState == FSTOnlineStateFailed) {
// If we're offline, set `current` to NO and then call applyChanges to refresh our syncState
// and generate an FSTViewChange as appropriate. We are guaranteed to get a new FSTTargetChange
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Source/Remote/FSTRemoteStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol FSTOnlineStateDelegate <NSObject>

/** Called whenever the online state of the watch stream changes */
- (void)watchStreamDidChangeOnlineState:(FSTOnlineState)onlineState;
- (void)applyChangedOnlineState:(FSTOnlineState)onlineState;

@end

Expand Down
2 changes: 1 addition & 1 deletion Firestore/Source/Remote/FSTRemoteStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ - (void)updateOnlineState:(FSTOnlineState)newState {
// Update and broadcast the new state.
if (newState != self.watchStreamOnlineState) {
self.watchStreamOnlineState = newState;
[self.onlineStateDelegate watchStreamDidChangeOnlineState:newState];
[self.onlineStateDelegate applyChangedOnlineState:newState];
}
}

Expand Down