Skip to content

Commit 7d873c4

Browse files
committed
fix(App): Fix potential memory leak with full screen event listeners
1 parent a16b5fe commit 7d873c4

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/electron/ipc-api/fullscreen.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const UPDATE_FULL_SCREEN_STATUS = 'set-full-screen-status';
2+
3+
export default ({ mainWindow }) => {
4+
mainWindow.on('enter-full-screen', () => {
5+
mainWindow.webContents.send(UPDATE_FULL_SCREEN_STATUS, true);
6+
});
7+
mainWindow.on('leave-full-screen', () => {
8+
mainWindow.webContents.send(UPDATE_FULL_SCREEN_STATUS, false);
9+
});
10+
};

src/electron/ipc-api/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import dnd from './dnd';
77
import desktopCapturer from './desktopCapturer';
88
import focusState from './focusState';
99
import serviceWebView from '../../features/serviceWebview/ipc';
10+
import fullscreenStatus from './fullscreen';
1011

1112
export default (params) => {
1213
settings(params);
@@ -18,4 +19,5 @@ export default (params) => {
1819
desktopCapturer();
1920
focusState(params);
2021
serviceWebView(params);
22+
fullscreenStatus(params);
2123
};

src/stores/AppStore.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { getLocale } from '../helpers/i18n-helpers';
2525
import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js';
2626
import { isValidExternalURL } from '../helpers/url-helpers';
2727
import { sleep } from '../helpers/async-helpers';
28+
import { UPDATE_FULL_SCREEN_STATUS } from '../electron/ipc-api/fullscreen';
2829

2930
const debug = require('debug')('Franz:AppStore');
3031

@@ -118,13 +119,9 @@ export default class AppStore extends Store {
118119
this.isOnline = false;
119120
});
120121

121-
mainWindow.on('enter-full-screen', () => {
122-
this.isFullScreen = true;
122+
document.addEventListener('onfullscreenchange', () => {
123+
console.log('fullscreen', document.fullscreenEnabled);
123124
});
124-
mainWindow.on('leave-full-screen', () => {
125-
this.isFullScreen = false;
126-
});
127-
128125

129126
this.isOnline = navigator.onLine;
130127

@@ -178,6 +175,10 @@ export default class AppStore extends Store {
178175
}
179176
});
180177

178+
ipcRenderer.on(UPDATE_FULL_SCREEN_STATUS, (e, status) => {
179+
this.isFullScreen = status;
180+
});
181+
181182
// Handle deep linking (franz://)
182183
ipcRenderer.on('navigateFromDeepLink', (event, data) => {
183184
debug('Navigate from deep link', data);

0 commit comments

Comments
 (0)