Skip to content

Commit e6dfb10

Browse files
authored
Remove absl::optional from firestore::api (#8225)
1 parent ecf3a3d commit e6dfb10

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

Firestore/Source/API/FIRFirestore.mm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,13 @@ - (FIRLoadBundleTask *)loadBundleStream:(NSInputStream *)bundleStream
435435

436436
- (void)getQueryNamed:(NSString *)name completion:(void (^)(FIRQuery *_Nullable query))completion {
437437
auto firestore = _firestore;
438-
auto callback = [completion, firestore](absl::optional<core::Query> query) {
438+
auto callback = [completion, firestore](core::Query query, bool found) {
439439
if (!completion) {
440440
return;
441441
}
442442

443-
if (query.has_value()) {
444-
FIRQuery *firQuery = [[FIRQuery alloc] initWithQuery:std::move(query.value())
445-
firestore:firestore];
443+
if (found) {
444+
FIRQuery *firQuery = [[FIRQuery alloc] initWithQuery:std::move(query) firestore:firestore];
446445
completion(firQuery);
447446
} else {
448447
completion(nil);

Firestore/core/src/api/api_fwd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ using DocumentSnapshotListener =
5353
using QuerySnapshotListener =
5454
std::unique_ptr<core::EventListener<QuerySnapshot>>;
5555

56-
using QueryCallback = std::function<void(absl::optional<core::Query>)>;
56+
using QueryCallback = std::function<void(core::Query, bool)>;
5757

5858
} // namespace api
5959
} // namespace firestore

Firestore/core/src/core/firestore_client.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,12 @@ void FirestoreClient::GetNamedQuery(const std::string& name,
535535
target.filters(), target.order_bys(), target.limit(),
536536
named_query.value().bundled_query().limit_type(),
537537
target.start_at(), target.end_at());
538-
user_executor_->Execute(
539-
[query, callback] { callback(std::move(query)); });
538+
user_executor_->Execute([query, callback] {
539+
callback(std::move(query), /*found=*/true);
540+
});
540541
} else {
541-
user_executor_->Execute([callback] { callback(absl::nullopt); });
542+
user_executor_->Execute(
543+
[callback] { callback(Query(), /*found=*/false); });
542544
}
543545
}
544546
};

0 commit comments

Comments
 (0)