Skip to content

Commit

Permalink
code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Leighton committed Aug 9, 2022
1 parent 73f4f66 commit d8ca1da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class RNBoltReactLibraryModule extends ReactContextBaseJavaModule {
private int REQUEST_PERMISSIONS = 1000;
private static final String TAG = "BoltSDK";
private BluetoothSearchResponseListener mBluetoothSearchResponseListener = null;
private Map<String, BluetoothDevice> mapDevices = Collections.synchronizedMap(new HashMap<String, BluetoothDevice>());
ReactApplicationContext context;
private boolean enableDebugging = false;

Expand Down Expand Up @@ -254,15 +253,12 @@ public void discoverDevice() {
@Override
public void onDeviceFound(BluetoothDevice device) {

synchronized (mapDevices) {

WritableMap params = Arguments.createMap();
WritableMap params = Arguments.createMap();

params.putString("id", device.getAddress());
params.putString("name", device.getName());
params.putString("id", device.getAddress());
params.putString("name", device.getName());

sendEvent("BoltDeviceFound", params);
}
sendEvent("BoltDeviceFound", params);
}
};

Expand Down
10 changes: 7 additions & 3 deletions ios/RNCardConnectReactLibrary.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#import <React/RCTLog.h>
#import <React/RCTConvert.h>

static NSString *const MESSAGE_CANCELLED_TRANSACTION = @"Canceled transaction.";
static NSString *const MESSAGE_FAILED_CONNECT = @"Failed to connect to device.";
static NSString *const MESSAGE_SWIPE_TAP_INSERT = @"PLEASE SWIPE,\nTAP, OR INSERT";

@implementation RNCardConnectReactLibrary

RCT_EXPORT_MODULE(BoltSDK)
Expand Down Expand Up @@ -156,7 +160,7 @@ - (void)swiper:(BMSSwiperController *)swiper configurationProgress:(float)progre
- (void)swiper:(BMSSwiperController *)swiper displayMessage:(NSString *)message canCancel:(BOOL)cancelable {

// special message we will convert into various events
if ([message isEqualToString:@"PLEASE SWIPE,\nTAP, OR INSERT"]) {
if ([message isEqualToString:MESSAGE_SWIPE_TAP_INSERT]) {

// device will automatically activate when connecting, so we silently cancel the transaction
if (self.isConnecting) {
Expand Down Expand Up @@ -262,7 +266,7 @@ - (void)swiper:(BMSSwiper *)swiper didFailWithError:(NSError *)error completion:
self.restartReaderBlock = completion;

// this error will get issued repeatedly while connecting, ignore
if (self.isConnecting && [error.localizedDescription isEqualToString:@"Failed to connect to device."]) {
if (self.isConnecting && [error.localizedDescription isEqualToString:MESSAGE_FAILED_CONNECT]) {
// this is where the error for failing to find the serial number surfaces
if (error.userInfo) {
[self debug:@"user info array"];
Expand All @@ -280,7 +284,7 @@ - (void)swiper:(BMSSwiper *)swiper didFailWithError:(NSError *)error completion:

// the device will automatically activate after connecting
// we cancel this transaction to complete the connection process
if (self.isConnecting && [error.localizedDescription isEqualToString:@"Canceled transaction."]) {
if (self.isConnecting && [error.localizedDescription isEqualToString:MESSAGE_CANCELLED_TRANSACTION]) {
[self sendEventWithName:@"BoltOnSwiperConnected" body:@{}];
self.isConnecting = false;
return;
Expand Down

0 comments on commit d8ca1da

Please sign in to comment.