mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-09-26 14:45:44 +00:00
check access on every event
This commit is contained in:
@@ -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
@@ -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.'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user