mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-08-08 10:12:50 +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
|
@ -18,20 +18,15 @@ if (TARGET === 'electron') {
|
|||
// @ts-ignore
|
||||
const electronAPI = __non_webpack_require__('electron');
|
||||
|
||||
// Since event is sent async during window startup, could fire off before or after renderer.js is loaded
|
||||
electronAPI.ipcRenderer.on('startup-storage-clear', () => {
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
electronAPI.ipcRenderer.on("device-info", (_event, value: any) => {
|
||||
preloadData.deviceInfo = value;
|
||||
})
|
||||
|
||||
electronAPI.contextBridge.exposeInMainWorld('targetAPI', {
|
||||
onStartupStorageClear: (callback: any) => electronAPI.ipcRenderer.on('startup-storage-clear', callback),
|
||||
onDeviceInfo: (callback: any) => electronAPI.ipcRenderer.on("device-info", callback),
|
||||
onConnect: (callback: any) => electronAPI.ipcRenderer.on("connect", callback),
|
||||
onDisconnect: (callback: any) => electronAPI.ipcRenderer.on("disconnect", callback),
|
||||
onPing: (callback: any) => electronAPI.ipcRenderer.on("ping", callback),
|
||||
getDeviceInfo: () => preloadData.deviceInfo,
|
||||
});
|
||||
|
||||
|
@ -39,17 +34,17 @@ if (TARGET === 'electron') {
|
|||
} else if (TARGET === 'webOS') {
|
||||
try {
|
||||
preloadData = {
|
||||
onStartupStorageClearCb: () => { localStorage.clear(); },
|
||||
onDeviceInfoCb: () => { console.log('Main: Callback not set while fetching device info'); },
|
||||
onConnectCb: (_, value: any) => { console.log('Main: Callback not set while calling onConnect'); },
|
||||
onDisconnectCb: (_, value: any) => { console.log('Main: Callback not set while calling onDisconnect'); },
|
||||
onPingCb: (_, value: any) => { console.log('Main: Callback not set while calling onPing'); },
|
||||
};
|
||||
|
||||
window.targetAPI = {
|
||||
onStartupStorageClear: (callback: () => void) => preloadData.onStartupStorageClearCb = callback,
|
||||
onDeviceInfo: (callback: () => void) => preloadData.onDeviceInfoCb = callback,
|
||||
onConnect: (callback: (_, value: any) => void) => preloadData.onConnectCb = callback,
|
||||
onDisconnect: (callback: (_, value: any) => void) => preloadData.onDisconnectCb = callback,
|
||||
onPing: (callback: (_, value: any) => void) => preloadData.onPingCb = callback,
|
||||
getDeviceInfo: () => preloadData.deviceInfo,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue