Skip to content

Fix a couple small issues I tripped over today. #2806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 11, 2019
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
13 changes: 7 additions & 6 deletions Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ - (void)setUp {
[super setUp];

[self clearPersistence];
[self primeBackend];

_firestores = [NSMutableArray array];
self.db = [self firestore];
Expand Down Expand Up @@ -202,14 +203,13 @@ - (FIRFirestore *)firestoreWithProjectID:(NSString *)projectID {

[_firestores addObject:firestore];

[self primeBackend:firestore];

return firestore;
}

- (void)primeBackend:(FIRFirestore *)db {
- (void)primeBackend {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
FIRFirestore *db = [self firestore];
XCTestExpectation *watchInitialized =
[self expectationWithDescription:@"Prime backend: Watch initialized"];
__block XCTestExpectation *watchUpdateReceived;
Expand Down Expand Up @@ -247,6 +247,8 @@ - (void)primeBackend:(FIRFirestore *)db {
}];

[listenerRegistration remove];

[self shutdownFirestore:db];
});
}

Expand Down Expand Up @@ -393,14 +395,13 @@ - (void)mergeDocumentRef:(FIRDocumentReference *)ref
}

- (void)disableNetwork {
[self.db.client
[self.db
disableNetworkWithCompletion:[self completionForExpectationWithName:@"Disable Network."]];
[self awaitExpectations];
}

- (void)enableNetwork {
[self.db.client
enableNetworkWithCompletion:[self completionForExpectationWithName:@"Enable Network."]];
[self.db enableNetworkWithCompletion:[self completionForExpectationWithName:@"Enable Network."]];
[self awaitExpectations];
}

Expand Down
1 change: 0 additions & 1 deletion Firestore/Source/API/FIRFirestore+Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ NS_ASSUME_NONNULL_BEGIN

// FIRFirestore ownes the DatabaseId instance.
@property(nonatomic, assign, readonly) const firebase::firestore::model::DatabaseId *databaseID;
@property(nonatomic, strong, readonly) FSTFirestoreClient *client;
@property(nonatomic, strong, readonly) FSTUserDataConverter *dataConverter;

@end
Expand Down
7 changes: 0 additions & 7 deletions Firestore/Source/API/FIRFirestore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,6 @@ - (void)setSettings:(FIRFirestoreSettings *)settings {
_firestore->set_settings(settings);
}

/**
* Ensures that the FirestoreClient is configured and returns it.
*/
- (FSTFirestoreClient *)client {
return _firestore->client();
}

- (FIRCollectionReference *)collectionWithPath:(NSString *)collectionPath {
if (!collectionPath) {
ThrowInvalidArgument("Collection path cannot be nil.");
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Source/API/FIRQuery.mm
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ - (void)getDocumentsWithSource:(FIRFirestoreSource)publicSource
NSError *_Nullable error))completion {
Source source = MakeSource(publicSource);
if (source == Source::Cache) {
[self.firestore.client getDocumentsFromLocalCache:self completion:completion];
[self.firestore.wrapped->client() getDocumentsFromLocalCache:self completion:completion];
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Firestore/Source/API/FIRWriteBatch.mm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ - (void)commit {
- (void)commitWithCompletion:(nullable void (^)(NSError *_Nullable error))completion {
[self verifyNotCommitted];
self.committed = TRUE;
[self.firestore.client writeMutations:std::move(_mutations) completion:completion];
[self.firestore.wrapped->client() writeMutations:std::move(_mutations) completion:completion];
}

- (void)verifyNotCommitted {
Expand Down
2 changes: 2 additions & 0 deletions Firestore/core/src/firebase/firestore/api/firestore.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "Firestore/core/src/firebase/firestore/auth/credentials_provider.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/util/async_queue.h"
#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -75,6 +76,7 @@ class Firestore {
}

FSTFirestoreClient* client() {
HARD_ASSERT(client_, "Client is not yet configured.");
return client_;
}

Expand Down