check access on every event

This commit is contained in:
Alexander Drozdov
2021-04-23 03:02:30 +03:00
parent 84a54207be
commit fd29115384
2 changed files with 14 additions and 13 deletions
+2 -2
View File
@@ -47,8 +47,8 @@ class PoeWindowClass extends EventEmitter {
OW.attachTo(window, config.get('windowTitle'))
}
onceAttached (cb: (hasAccess: boolean | undefined) => void) {
OW.once('attach', (e: AttachEvent) => {
onAttach (cb: (hasAccess: boolean | undefined) => void) {
OW.on('attach', (e: AttachEvent) => {
cb(e.hasAccess)
})
}
+12 -11
View File
@@ -16,11 +16,20 @@ export const overlayReady = new Promise<void>((resolve) => {
})
export async function createOverlayWindow () {
if (process.platform === 'win32' && !systemPreferences.isAeroGlassEnabled()) {
dialog.showErrorBox(
'Windows 7 - Aero',
// ----------------------
'You must enable Windows Aero in "Appearance and Personalization".\n' +
'It is required to create a transparent overlay window.'
)
}
ipcMain.once(ipc.OVERLAY_READY, _resolveOverlayReady)
ipcMain.on(ipc.DPR_CHANGE, (_: any, dpr: number) => handleDprChange(dpr))
ipcMain.on(ipc.CLOSE_OVERLAY, assertPoEActive)
PoeWindow.on('active-change', handlePoeWindowActiveChange)
PoeWindow.onceAttached(handleOverlayAttached)
PoeWindow.onAttach(handleOverlayAttached)
overlayWindow = new BrowserWindow({
icon: path.join(__static, 'icon.png'),
@@ -118,6 +127,8 @@ function focusPoE () {
function handleOverlayAttached (hasAccess?: boolean) {
if (hasAccess === false) {
logger.error('PoE is running with administrator rights', { source: 'overlay' })
dialog.showErrorBox(
'PoE window - No access',
// ----------------------
@@ -125,16 +136,6 @@ function handleOverlayAttached (hasAccess?: boolean) {
'\n' +
'You need to restart Awakened PoE Trade with administrator rights.'
)
return
}
if (process.platform === 'win32' && !systemPreferences.isAeroGlassEnabled()) {
dialog.showErrorBox(
'Windows 7 - Aero',
// ----------------------
'You must enable Windows Aero in "Appearance and Personalization".\n' +
'It is required to create a transparent overlay window.'
)
}
}