Skip to content

Commit

Permalink
Validate ID response from 3D printer and track by mainboard ID. Fixes #5
Browse files Browse the repository at this point in the history
. Fixes #6.
  • Loading branch information
ssewell committed Sep 11, 2023
1 parent f64370f commit 53d1954
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@ import '../components/ProgressBar.css';
import Printer from 'components/Printer';
import { PrinterItem } from 'types/PrinterTypes';

const RESPONSE_ID = 'f25273b12b094c5a8b9513a30ca60049'; // Id included in valid JSON response from 3D printer

export default function App() {
const [data, setData] = useState<Record<string, PrinterItem>>({});
const [debugMode, setDebugMode] = useState(false);

useEffect(() => {
return window.electron.ipcRenderer.on('update-printers', (udpData: any) => {
const udpDataJson: PrinterItem = JSON.parse(udpData);

if (udpDataJson.Id !== RESPONSE_ID) return;

setData((prevData) => ({
...prevData,
[udpDataJson.Id]: udpDataJson,
[udpDataJson.Data.Attributes.MainboardID]: udpDataJson,
}));
});
}, []);
Expand Down

0 comments on commit 53d1954

Please sign in to comment.