diff --git a/app/main.ts b/app/main.ts index 9131a87..60c1de3 100644 --- a/app/main.ts +++ b/app/main.ts @@ -8,10 +8,10 @@ import * as https from 'https'; import { createHash } from 'crypto'; import * as tar from 'tar'; import * as os from 'os'; -import * as pidusage from 'pidusage'; import AutoLaunch from './auto-launch'; -import * as AdmZip from 'adm-zip'; +import AdmZip from 'adm-zip'; +const pidusage = require('pidusage'); const batteryLevel = require('battery-level'); const network = require('network'); @@ -205,7 +205,7 @@ function createWindow(): BrowserWindow { allowRunningInsecureContent: (serve), contextIsolation: true, devTools: !app.isPackaged, - sandbox: false + sandbox: true }, show: false, autoHideMenuBar: true, @@ -495,7 +495,6 @@ function monitorMonerod(): void { } win?.webContents.send('on-monitor-monerod', stats); - }); } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index ac30c14..6f104e7 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,6 +1,5 @@ import { Component } from '@angular/core'; import { ElectronService } from './core/services'; -import { APP_CONFIG } from '../environments/environment'; import { DaemonService } from './core/services/daemon/daemon.service'; import { DaemonDataService } from './core/services/daemon/daemon-data.service'; import { LogsService } from './pages/logs/logs.service'; @@ -26,17 +25,6 @@ export class AppComponent { private LogService: LogsService, private trayService: DaemonTrayService ) { - console.log('APP_CONFIG', APP_CONFIG); - - if (electronService.isElectron) { - console.log(process.env); - console.log('Run in electron'); - console.log('Electron ipcRenderer', this.electronService.ipcRenderer); - console.log('NodeJS childProcess', this.electronService.childProcess); - } else { - console.log('Run in browser'); - } - this.load().then().catch((error: any) => console.error(error)); } diff --git a/src/app/core/services/daemon/daemon-data.service.ts b/src/app/core/services/daemon/daemon-data.service.ts index cee4732..0a2fcff 100644 --- a/src/app/core/services/daemon/daemon-data.service.ts +++ b/src/app/core/services/daemon/daemon-data.service.ts @@ -509,9 +509,11 @@ export class DaemonDataService { this._txPoolStats = undefined; } - this._gettingConnections = true; - this._connections = await this.daemonService.getConnections(); - this._gettingConnections = false; + if (!this.daemonService.settings.offline) { + this._gettingConnections = true; + this._connections = await this.daemonService.getConnections(); + this._gettingConnections = false; + } this._lastRefreshHeight = this._daemonInfo.heightWithoutBootstrap; this._lastRefresh = Date.now(); diff --git a/src/app/core/services/electron/electron.service.ts b/src/app/core/services/electron/electron.service.ts index 35d7554..5ec5cfa 100644 --- a/src/app/core/services/electron/electron.service.ts +++ b/src/app/core/services/electron/electron.service.ts @@ -1,60 +1,31 @@ import { Injectable } from '@angular/core'; // If you import a module but never use any of the imported values other than as TypeScript types, // the resulting javascript file will look as if you never imported the module at all. -import { ipcRenderer, webFrame } from 'electron'; import * as childProcess from 'child_process'; import * as fs from 'fs'; +import { APP_CONFIG } from '../../../../environments/environment'; @Injectable({ providedIn: 'root' }) export class ElectronService { - ipcRenderer!: typeof ipcRenderer; - webFrame!: typeof webFrame; childProcess!: typeof childProcess; fs!: typeof fs; private _isAppImage?: boolean; private _isAutoLaunched?: boolean; private _online: boolean = false; + private _isProduction: boolean = false; + + public get isProduction(): boolean { + return this._isProduction; + } constructor() { - // Conditional imports - if (this.isElectron) { - this.ipcRenderer = (window as any).require('electron').ipcRenderer; - this.webFrame = (window as any).require('electron').webFrame; - - this.fs = (window as any).require('fs'); - - this.childProcess = (window as any).require('child_process'); - this.childProcess.exec('node -v', (error, stdout, stderr) => { - if (error) { - console.error(`error: ${error.message}`); - return; - } - if (stderr) { - console.error(`stderr: ${stderr}`); - return; - } - console.log(`stdout:\n${stdout}`); - }); - - // Notes : - // * A NodeJS's dependency imported with 'window.require' MUST BE present in `dependencies` of both `app/package.json` - // and `package.json (root folder)` in order to make it work here in Electron's Renderer process (src folder) - // because it will loaded at runtime by Electron. - // * A NodeJS's dependency imported with TS module import (ex: import { Dropbox } from 'dropbox') CAN only be present - // in `dependencies` of `package.json (root folder)` because it is loaded during build phase and does not need to be - // in the final bundle. Reminder : only if not used in Electron's Main process (app folder) - - // If you want to use a NodeJS 3rd party deps in Renderer process, - // ipcRenderer.invoke can serve many common use cases. - // https://www.electronjs.org/docs/latest/api/ipc-renderer#ipcrendererinvokechannel-args - } - this._online = navigator.onLine; window.addEventListener('online', () => this._online = true); window.addEventListener('offline', () => this._online = false); + this._isProduction = APP_CONFIG.production; } public get online(): boolean { diff --git a/src/app/pages/mining/mining.component.ts b/src/app/pages/mining/mining.component.ts index bec5328..b077f31 100644 --- a/src/app/pages/mining/mining.component.ts +++ b/src/app/pages/mining/mining.component.ts @@ -327,8 +327,7 @@ export class MiningComponent extends BasePageComponent implements AfterViewInit, return true; - } catch (error: any) { - console.debug(error); + } catch { return false; } }