From 75bfa327034401468e69bd591da5546eb02d9732 Mon Sep 17 00:00:00 2001 From: eliaslecomte Date: Mon, 5 Sep 2022 19:05:27 +0200 Subject: [PATCH] fix: prefer not to mutate the ScanResult object --- .../rnwifi/mappers/WifiScanResultsMapper.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/reactlibrary/rnwifi/mappers/WifiScanResultsMapper.java b/android/src/main/java/com/reactlibrary/rnwifi/mappers/WifiScanResultsMapper.java index aeda149..6ef5c4c 100644 --- a/android/src/main/java/com/reactlibrary/rnwifi/mappers/WifiScanResultsMapper.java +++ b/android/src/main/java/com/reactlibrary/rnwifi/mappers/WifiScanResultsMapper.java @@ -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 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);