Skip to content

Commit 2284e69

Browse files
committed
Minor fixes
1 parent b9c0393 commit 2284e69

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/CustomCheckoutEventProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public class CustomCheckoutEventProcessor extends DefaultCheckoutEventProcessor
4949

5050
private String geolocationOrigin;
5151
private GeolocationPermissions.Callback geolocationCallback;
52-
private boolean retainGeolocationForFutureRequests = true;
5352

5453
public CustomCheckoutEventProcessor(Context context, ReactApplicationContext reactContext) {
5554
super(context);
@@ -60,6 +59,7 @@ public CustomCheckoutEventProcessor(Context context, ReactApplicationContext rea
6059

6160
public void invokeGeolocationCallback(boolean allow) {
6261
if (geolocationCallback != null) {
62+
boolean retainGeolocationForFutureRequests = false;
6363
geolocationCallback.invoke(geolocationOrigin, allow, retainGeolocationForFutureRequests);
6464
geolocationCallback = null;
6565
}
@@ -90,8 +90,8 @@ public void onGeolocationPermissionsShowPrompt(@NonNull String origin,
9090

9191
// Emit a "geolocationRequest" event to the app.
9292
try {
93-
Map<String, Object> event = new HashMap();
94-
event.put("origin", origin.toString());
93+
Map<String, Object> event = new HashMap<>();
94+
event.put("origin", origin);
9595
sendEventWithStringData("geolocationRequest", mapper.writeValueAsString(event));
9696
} catch (IOException e) {
9797
Log.e("ShopifyCheckoutSheetKit", "Error emitting \"geolocationRequest\" event", e);

modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitModule.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public class ShopifyCheckoutSheetKitModule extends ReactContextBaseJavaModule {
4848

4949
private CheckoutSheetKitDialog checkoutSheet;
5050

51+
private CustomCheckoutEventProcessor checkoutEventProcessor;
52+
5153
public ShopifyCheckoutSheetKitModule(ReactApplicationContext reactContext) {
5254
super(reactContext);
5355

@@ -86,8 +88,7 @@ public void removeListeners(Integer count) {
8688
public void present(String checkoutURL) {
8789
Activity currentActivity = getCurrentActivity();
8890
if (currentActivity instanceof ComponentActivity) {
89-
DefaultCheckoutEventProcessor checkoutEventProcessor = new CustomCheckoutEventProcessor(currentActivity,
90-
this.reactContext);
91+
checkoutEventProcessor = new CustomCheckoutEventProcessor(currentActivity, this.reactContext);
9192
currentActivity.runOnUiThread(() -> {
9293
checkoutSheet = ShopifyCheckoutSheetKit.present(checkoutURL, (ComponentActivity) currentActivity,
9394
checkoutEventProcessor);
@@ -163,7 +164,9 @@ public void setConfig(ReadableMap config) {
163164

164165
@ReactMethod
165166
public void initiateGeolocationRequest(Boolean allow) {
166-
checkoutEventProcessor.invokeGeolocationCallback(allow);
167+
if (checkoutEventProcessor != null) {
168+
checkoutEventProcessor.invokeGeolocationCallback(allow);
169+
}
167170
}
168171

169172
// Private

0 commit comments

Comments
 (0)