From 2b366ebf5cef26992581335056d076d91af22596 Mon Sep 17 00:00:00 2001 From: louisg1337 Date: Mon, 19 Feb 2024 15:34:46 -0500 Subject: [PATCH] Fixed weird react hook error by passing in the translation hook into our bluetooth scanner --- www/js/bluetooth/BluetoothScanPage.tsx | 3 ++- www/js/bluetooth/blueoothScanner.ts | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/www/js/bluetooth/BluetoothScanPage.tsx b/www/js/bluetooth/BluetoothScanPage.tsx index 777aaa95d..40dac9306 100644 --- a/www/js/bluetooth/BluetoothScanPage.tsx +++ b/www/js/bluetooth/BluetoothScanPage.tsx @@ -5,6 +5,7 @@ import gatherBluetoothData from './blueoothScanner'; import { logWarn } from '../plugin/logger'; import BluetoothCard from './BluetoothCard'; import { Appbar, useTheme, Button } from 'react-native-paper'; +// import useBluetoothScan from '../bluetooth/blueoothScanner' /** * The implementation of this scanner page follows the design of @@ -22,7 +23,7 @@ const BluetoothScanPage = ({ ...props }: any) => { // Function to run Bluetooth test and update logs const runBluetoothTest = async () => { try { - const newLogs = await gatherBluetoothData(); + const newLogs = await gatherBluetoothData(t); setLogs(newLogs); } catch (error) { logWarn(error); diff --git a/www/js/bluetooth/blueoothScanner.ts b/www/js/bluetooth/blueoothScanner.ts index efad6aea7..10b36b498 100644 --- a/www/js/bluetooth/blueoothScanner.ts +++ b/www/js/bluetooth/blueoothScanner.ts @@ -1,11 +1,10 @@ -import { logWarn } from '../plugin/logger'; -import { useTranslation } from 'react-i18next'; +import { logWarn, logDebug } from '../plugin/logger'; -export function gatherBluetoothData(): Promise { - const { t } = useTranslation(); +export default function gatherBluetoothData(t): Promise { return new Promise((resolve, reject) => { let logs: string[] = []; + logDebug("Running bluetooth discovery test!"); window['bluetoothSerial'].discoverUnpaired( (devices: Array) => { @@ -26,6 +25,4 @@ export function gatherBluetoothData(): Promise { }, ); }); -} - -export default gatherBluetoothData; +} \ No newline at end of file