Fix isStandalone when PWA entering fullscreen (#156424)

Fixes https://github.com/microsoft/vscode/issues/156347
This commit is contained in:
Ping
2022-08-02 13:20:42 +08:00
committed by GitHub
parent 0fffd354d3
commit 8bd41544ee
+10 -3
View File
@@ -194,9 +194,16 @@ export const isAndroid = (userAgent.indexOf('Android') >= 0);
let standalone = false;
if (window.matchMedia) {
const matchMedia = window.matchMedia('(display-mode: standalone)');
standalone = matchMedia.matches;
addMatchMediaChangeListener(matchMedia, ({ matches }) => {
const standaloneMatchMedia = window.matchMedia('(display-mode: standalone)');
const fullScreenMatchMedia = window.matchMedia('(display-mode: fullscreen)');
standalone = standaloneMatchMedia.matches;
addMatchMediaChangeListener(standaloneMatchMedia, ({ matches }) => {
// entering fullscreen would change standaloneMatchMedia.matches to false
// if standalone is true (running as PWA) and entering fullscreen, skip this change
if (standalone && fullScreenMatchMedia.matches) {
return;
}
// otherwise update standalone (browser to PWA or PWA to browser)
standalone = matches;
});
}