mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-06-24 21:25:23 +00:00
Fix code in onDeviceInfo not always being ran
This commit is contained in:
parent
bda9253c6d
commit
e0716259a5
2 changed files with 19 additions and 5 deletions
|
@ -1,5 +1,11 @@
|
||||||
const { contextBridge, ipcRenderer } = require('electron');
|
const { contextBridge, ipcRenderer } = require('electron');
|
||||||
|
|
||||||
|
let deviceInfo;
|
||||||
|
ipcRenderer.on("device-info", (_event, value) => {
|
||||||
|
deviceInfo = value;
|
||||||
|
})
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('electronAPI', {
|
contextBridge.exposeInMainWorld('electronAPI', {
|
||||||
onDeviceInfo: (callback) => ipcRenderer.on("device-info", callback)
|
onDeviceInfo: (callback) => ipcRenderer.on("device-info", callback),
|
||||||
});
|
getDeviceInfo: () => deviceInfo,
|
||||||
|
});
|
||||||
|
|
|
@ -10,8 +10,16 @@ const player = videojs("video-player", options, function onPlayerReady() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
window.electronAPI.onDeviceInfo((_event, value) => {
|
window.electronAPI.onDeviceInfo(renderIPsAndQRCode);
|
||||||
console.log("onDeviceInfo", value);
|
|
||||||
|
if(window.electronAPI.getDeviceInfo()) {
|
||||||
|
console.log("device info already present");
|
||||||
|
renderIPsAndQRCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderIPsAndQRCode() {
|
||||||
|
const value = window.electronAPI.getDeviceInfo();
|
||||||
|
console.log("device info", value);
|
||||||
|
|
||||||
const ipsElement = document.getElementById('ips');
|
const ipsElement = document.getElementById('ips');
|
||||||
if (ipsElement) {
|
if (ipsElement) {
|
||||||
|
@ -42,4 +50,4 @@ window.electronAPI.onDeviceInfo((_event, value) => {
|
||||||
colorLight : "#ffffff",
|
colorLight : "#ffffff",
|
||||||
correctLevel : QRCode.CorrectLevel.M
|
correctLevel : QRCode.CorrectLevel.M
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue