mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-08-08 02:02:49 +00:00
Changed connection detection on window re-create
This commit is contained in:
parent
bff3440a8e
commit
9a7924ebce
7 changed files with 32 additions and 45 deletions
|
@ -6,22 +6,19 @@ import { toast, ToastIcon } from '../components/Toast';
|
|||
const connectionStatusText = document.getElementById("connection-status-text");
|
||||
const connectionStatusSpinner = document.getElementById("connection-spinner");
|
||||
const connectionStatusCheck = document.getElementById("connection-check");
|
||||
let connections = JSON.parse(localStorage.getItem('connections')) ?? [];
|
||||
if (connections.length > 0) {
|
||||
connections.forEach(connection => {
|
||||
onConnect(connection);
|
||||
});
|
||||
}
|
||||
let connections = [];
|
||||
|
||||
window.targetAPI.onStartupStorageClear((_event, value: any) => {
|
||||
localStorage.clear();
|
||||
localStorage.setItem('connections', JSON.stringify(connections));
|
||||
// Window might be re-created while devices are still connected
|
||||
window.targetAPI.onPing((_event, value: any) => {
|
||||
if (connections.length === 0) {
|
||||
connections.push(value.id);
|
||||
onConnect(value.id);
|
||||
}
|
||||
});
|
||||
|
||||
window.targetAPI.onDeviceInfo(renderIPsAndQRCode);
|
||||
window.targetAPI.onConnect((_event, value: any) => {
|
||||
connections.push(value.id);
|
||||
localStorage.setItem('connections', JSON.stringify(connections));
|
||||
onConnect(value);
|
||||
});
|
||||
window.targetAPI.onDisconnect((_event, value: any) => {
|
||||
|
@ -29,7 +26,6 @@ window.targetAPI.onDisconnect((_event, value: any) => {
|
|||
const index = connections.indexOf(value.id);
|
||||
if (index != -1) {
|
||||
connections.splice(index, 1);
|
||||
localStorage.setItem('connections', JSON.stringify(connections));
|
||||
}
|
||||
|
||||
if (connections.length === 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue