Skip to content

Commit

Permalink
fix: fix "hasWheelchairAccessibleEntrance" boolean field due to API c…
Browse files Browse the repository at this point in the history
…hanges

PiperOrigin-RevId: 609792119
  • Loading branch information
mcreinhard authored and copybara-github committed Feb 23, 2024
1 parent 5fed3e7 commit 3df3d09
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function getFieldValue(place: Place, field: PlaceBooleanField): boolean|null|
case 'hasTakeout':
return place.hasTakeout;
case 'hasWheelchairAccessibleEntrance':
return place.hasWheelchairAccessibleEntrance;
return place.accessibilityOptions?.hasWheelchairAccessibleEntrance;
case 'isReservable':
return place.isReservable;
case 'servesBeer':
Expand Down Expand Up @@ -191,14 +191,17 @@ export class PlaceFieldBoolean extends PlaceDataConsumer {
getRequiredFields(): Array<keyof Place> {
if (!this.field) return [];
const placeField = toPlaceBooleanField(this.field);
if (placeField === 'isOpen()') {
return [
'businessStatus',
'openingHours',
'utcOffsetMinutes',
];
} else {
return [placeField];
switch (placeField) {
case 'isOpen()':
return [
'businessStatus',
'openingHours',
'utcOffsetMinutes',
];
case 'hasWheelchairAccessibleEntrance':
return ['accessibilityOptions'];
default:
return [placeField];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('place field boolean test', () => {
hasDelivery: true,
hasDineIn: true,
hasTakeout: true,
hasWheelchairAccessibleEntrance: true,
accessibilityOptions: {hasWheelchairAccessibleEntrance: true},
isReservable: true,
servesBeer: true,
servesBreakfast: true,
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('place field boolean test', () => {
hasDelivery: false,
hasDineIn: false,
hasTakeout: false,
hasWheelchairAccessibleEntrance: false,
accessibilityOptions: {hasWheelchairAccessibleEntrance: false},
isReservable: false,
servesBeer: false,
servesBreakfast: false,
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('place field boolean test', () => {
hasDelivery: null,
hasDineIn: null,
hasTakeout: null,
hasWheelchairAccessibleEntrance: null,
accessibilityOptions: {hasWheelchairAccessibleEntrance: null},
isReservable: null,
servesBeer: null,
servesBreakfast: null,
Expand Down Expand Up @@ -362,4 +362,4 @@ describe('place field boolean test', () => {

expect(lifecycleSpy.hostUpdatedCount).toBe(2);
});
});
});
8 changes: 5 additions & 3 deletions src/utils/googlemaps_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ export declare interface SearchByTextRequest {
}

/** Updated Place class with new attribution schema. */
export declare type Place =
Omit<google.maps.places.Place, 'photos'|'reviews'|'fetchFields'>& {
export declare interface Place extends Omit<
google.maps.places.Place,
'photos'|'reviews'|'fetchFields'|'hasWheelchairAccessibleEntrance'> {
photos?: Photo[];
reviews?: Review[];
accessibilityOptions?: {hasWheelchairAccessibleEntrance: boolean|null}|null;
fetchFields: (options: google.maps.places.FetchFieldsRequest) =>
Promise<{place: Place}>;
};
}

/** Places library. */
export declare interface PlacesLibrary extends
Expand Down

0 comments on commit 3df3d09

Please sign in to comment.