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,
async open (ws)
{
const valuesObject = {
battery: 'percent, isCharging, acConnected, hasBattery'
};
const battery = await si.battery();
const wifi = await si.wifiConnections();
const bluetooth = await si.bluetoothDevices();
@ -78,28 +74,23 @@ export const system = new Elysia({ prefix: '/api/system' })
bluetoothDevices: bluetooth
}, 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)
{
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 () =>
{
const drives = await getDevices();