Skip to content

Commit

Permalink
fix: prefer not to mutate the ScanResult object (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliaslecomte authored May 26, 2023
1 parent 49a59ba commit 840c80d
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ public class WifiScanResultsMapper {
private WifiScanResultsMapper() {
}

private static String parseSSID(final ScanResult scanResult) {
if (scanResult.SSID.equals("")) {
return "(hidden SSID)";
}

return scanResult.SSID;
}

public static WritableArray mapWifiScanResults(final List<ScanResult> scanResults) {
final WritableArray wifiArray = new WritableNativeArray();

for (ScanResult result : scanResults) {
final WritableMap wifiObject = new WritableNativeMap();
if (result.SSID.equals("")) {
result.SSID = "(hidden SSID)";
}
wifiObject.putString("SSID", result.SSID);
wifiObject.putString("SSID", parseSSID(result));
wifiObject.putString("BSSID", result.BSSID);
wifiObject.putString("capabilities", result.capabilities);
wifiObject.putInt("frequency", result.frequency);
Expand Down

0 comments on commit 840c80d

Please sign in to comment.