Skip to content

Commit

Permalink
Fixed weird react hook error by passing in the translation hook into …
Browse files Browse the repository at this point in the history
…our bluetooth scanner
  • Loading branch information
louisg1337 committed Feb 19, 2024
1 parent b4cafd4 commit 2b366eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion www/js/bluetooth/BluetoothScanPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
11 changes: 4 additions & 7 deletions www/js/bluetooth/blueoothScanner.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { logWarn } from '../plugin/logger';
import { useTranslation } from 'react-i18next';
import { logWarn, logDebug } from '../plugin/logger';

export function gatherBluetoothData(): Promise<string[]> {
const { t } = useTranslation();
export default function gatherBluetoothData(t): Promise<string[]> {

return new Promise((resolve, reject) => {
let logs: string[] = [];
logDebug("Running bluetooth discovery test!");

window['bluetoothSerial'].discoverUnpaired(
(devices: Array<any>) => {
Expand All @@ -26,6 +25,4 @@ export function gatherBluetoothData(): Promise<string[]> {
},
);
});
}

export default gatherBluetoothData;
}

0 comments on commit 2b366eb

Please sign in to comment.