// Listen to changes in windows
overwolf.windows.onStateChanged.addListener(async () => {
const windowsStates = await this.windowsService.getWindowsStates();
console.log('windowsStates', JSON.stringify(windowsStates));
// If all UI (non-background) windows are closed, close the app
const shouldClose = Object.entries(windowsStates)
.filter(([windowName, windowState]) => {
console.log('in filter - windowName', windowName);
return windowName !== 'background';
})
.every(([windowName, windowState]) => {
console.log('in every - windowState', windowState);
return windowState === 'closed';
});
if (shouldClose) {
window.close();
}
windowsStates {"success":true,"status":"success","result":{"background":"minimized","nodge":"closed","ingame":"closed","desktop":"closed"},"resultV2":{"background":"hidden","nodge":"closed","ingame":"closed","desktop":"closed"}}
background-controller.js:48 in filter - windowName success
background-controller.js:48 in filter - windowName status
background-controller.js:48 in filter - windowName result
background-controller.js:48 in filter - windowName resultV2
background-controller.js:52 in every - windowState true
I think this has an implementation issue based on my logs: https://github.com/overwolf/sample-app/blob/master/native/windows/background/background-controller.js#L41