fix: Manual checking for system info to fix bug in library

This commit is contained in:
Simeon Radivoev 2026-03-28 20:55:45 +02:00
parent 816d50ae4d
commit a7eb655a48
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A

View file

@ -65,10 +65,6 @@ export const system = new Elysia({ prefix: '/api/system' })
response: SystemInfoSchema, response: SystemInfoSchema,
async open (ws) async open (ws)
{ {
const valuesObject = {
battery: 'percent, isCharging, acConnected, hasBattery'
};
const battery = await si.battery(); const battery = await si.battery();
const wifi = await si.wifiConnections(); const wifi = await si.wifiConnections();
const bluetooth = await si.bluetoothDevices(); const bluetooth = await si.bluetoothDevices();
@ -78,28 +74,23 @@ export const system = new Elysia({ prefix: '/api/system' })
bluetoothDevices: bluetooth bluetoothDevices: bluetooth
}, true); }, true);
(ws.data as any).observer = si.observe(valuesObject, 1000 * 30, (data) => (ws.data as any).observer = setInterval(async () =>
{ {
ws.send(data); const battery = await si.battery();
}); const wifi = await si.wifiConnections();
const bluetooth = await si.bluetoothDevices();
ws.send({
battery: battery,
wifiConnections: wifi,
bluetoothDevices: bluetooth
}, true);
}, 1000 * 30);
}, },
close (ws) close (ws)
{ {
clearInterval((ws.data as any).observer); clearInterval((ws.data as any).observer);
} }
}) })
.get('/info/battery', async () =>
{
return si.battery();
})
.get('/info/wifi', async () =>
{
return si.wifiConnections();
})
.get('/info/bluetooth', async () =>
{
return si.bluetoothDevices();
})
.get('/drives', async () => .get('/drives', async () =>
{ {
const drives = await getDevices(); const drives = await getDevices();