1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00

wrap window state in try catch

This commit is contained in:
Andrew Simachev 2025-05-09 21:24:55 +02:00
parent d7cfcdf648
commit 20e3a8d5c2
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF

View file

@ -113,15 +113,11 @@ class WindowManager {
});
} catch (e) {};
} else {
const { screen } = require('electron');
const primaryDisplay = screen.getPrimaryDisplay();
const { width, height } = primaryDisplay.workAreaSize;
const { width, height } = this.getScreenSize();
param = Object.assign(param, this.getWindowPosition(param, width, height));
};
console.log('PARAM', param);
const win = this.create(options, param);
if (!isChild) {
@ -142,9 +138,7 @@ class WindowManager {
};
createChallenge (options) {
const { screen } = require('electron');
const primaryDisplay = screen.getPrimaryDisplay();
const { width, height } = primaryDisplay.workAreaSize;
const { width, height } = this.getScreenSize();
const win = this.create({ ...options, isChallenge: true }, {
backgroundColor: '',
@ -171,6 +165,21 @@ class WindowManager {
return win;
};
getScreenSize () {
const ret = { width: DEFAULT_WIDTH, height: DEFAULT_HEIGHT };
try {
const { screen } = require('electron');
const primaryDisplay = screen.getPrimaryDisplay();
const { width, height } = primaryDisplay.workAreaSize;
ret.width = width;
ret.height = height;
} catch (e) {};
return ret;
};
closeChallenge (options) {
for (const win of this.list) {
if (win && win.isChallenge && (win.challenge == options.challenge) && !win.isDestroyed()) {