bundled electron app starts without error

This commit is contained in:
Jan Prochazka
2021-12-16 13:25:57 +01:00
parent e636987f31
commit 588b8b23f9
17 changed files with 91 additions and 59 deletions

View File

@@ -15,15 +15,19 @@ const doDatabasePing = value => {
};
let openedConnectionsHandle = null;
openedConnections.subscribe(value => {
doServerPing(value);
if (openedConnectionsHandle) window.clearInterval(openedConnectionsHandle);
openedConnectionsHandle = window.setInterval(() => doServerPing(value), 30 * 1000);
});
let currentDatabaseHandle = null;
currentDatabase.subscribe(value => {
doDatabasePing(value);
if (currentDatabaseHandle) window.clearInterval(currentDatabaseHandle);
currentDatabaseHandle = window.setInterval(() => doDatabasePing(value), 30 * 1000);
});
export function subscribeConnectionPingers() {
openedConnections.subscribe(value => {
doServerPing(value);
if (openedConnectionsHandle) window.clearInterval(openedConnectionsHandle);
openedConnectionsHandle = window.setInterval(() => doServerPing(value), 30 * 1000);
});
currentDatabase.subscribe(value => {
doDatabasePing(value);
if (currentDatabaseHandle) window.clearInterval(currentDatabaseHandle);
currentDatabaseHandle = window.setInterval(() => doDatabasePing(value), 30 * 1000);
});
}

View File

@@ -48,12 +48,12 @@ export async function exportElectronFile(dataName, reader, format) {
function handleRunnerDone() {
closeSnackbar(snackId);
socket.off(`runner-done-${runid}`, handleRunnerDone);
socket().off(`runner-done-${runid}`, handleRunnerDone);
if (isCanceled) showSnackbarError(`Export ${dataName} canceled`);
else showSnackbarInfo(`Export ${dataName} finished`);
}
socket.on(`runner-done-${runid}`, handleRunnerDone);
socket().on(`runner-done-${runid}`, handleRunnerDone);
}
export async function saveFileToDisk(

View File

@@ -16,14 +16,13 @@ class ElectronApi {
let apiInstance = null;
function initializeElectron(args) {
// console.log('Initialize electron with args:', args);
apiInstance = new ElectronApi(args);
if (window['dbgate_recreateAxiosInstance']) {
// console.log('Recreating axios instance');
window['dbgate_recreateAxiosInstance']();
}
if (window['dbgate_recreateSocket']) {
window['dbgate_recreateSocket']();
}
}
window['dbgate_initializeElectron'] = initializeElectron;

View File

@@ -3,13 +3,14 @@ import { useConfig } from './metadataLoaders';
let compiled = null;
const config = useConfig();
config.subscribe(value => {
if (!value) return;
const { permissions } = value;
compiled = compilePermissions(permissions);
});
export default function hasPermission(tested) {
return testPermission(tested, compiled);
}
export function subscribePermissionCompiler() {
useConfig().subscribe(value => {
if (!value) return;
const { permissions } = value;
compiled = compilePermissions(permissions);
});
}

View File

@@ -208,11 +208,11 @@ function useCore(loader, args) {
handleReload();
if (reloadTrigger && socket) {
for (const item of getAsArray(reloadTrigger)) {
socket.on(item, handleReload);
socket().on(item, handleReload);
}
return () => {
for (const item of getAsArray(reloadTrigger)) {
socket.off(item, handleReload);
socket().off(item, handleReload);
}
};
}

View File

@@ -1,8 +1,23 @@
import io from 'socket.io-client';
import resolveApi from './resolveApi';
import { cacheClean } from './cache';
import { shouldWaitForElectronInitialize } from './getElectron';
const socket = io(resolveApi());
socket.on('clean-cache', reloadTrigger => cacheClean(reloadTrigger));
let socketInstance;
function recreateSocket() {
if (shouldWaitForElectronInitialize()) return;
socketInstance = io(resolveApi());
socketInstance.on('clean-cache', reloadTrigger => cacheClean(reloadTrigger));
}
window['dbgate_recreateSocket'] = recreateSocket;
recreateSocket();
function socket() {
return socketInstance;
}
export default socket;