Skip to content

Commit

Permalink
fix: reload when firefox pinned tab becomes visible (#535)
Browse files Browse the repository at this point in the history
Co-authored-by: Baptiste Grob <[email protected]>
  • Loading branch information
Mo Bitar and arielsvg authored Mar 22, 2021
1 parent 232d017 commit cf76e1b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions app/assets/javascripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import { SessionsModalDirective } from './components/SessionsModal';
import { NoAccountWarningDirective } from './components/NoAccountWarning';
import { NoProtectionsdNoteWarningDirective } from './components/NoProtectionsNoteWarning';


function reloadHiddenFirefoxTab(): boolean {
/**
* For Firefox pinned tab issue:
Expand All @@ -67,14 +66,15 @@ function reloadHiddenFirefoxTab(): boolean {
*/
if (
document.hidden &&
navigator.userAgent.toLowerCase().includes('firefox') &&
!localStorage.getItem('reloading')
navigator.userAgent.toLowerCase().includes('firefox')
) {
localStorage.setItem('reloading', 'true');
location.reload();
document.addEventListener('visibilitychange', () => {
if (!document.hidden) {
location.reload();
}
});
return true;
} else {
localStorage.removeItem('reloading');
return false;
}
}
Expand Down Expand Up @@ -170,7 +170,10 @@ const startApplication: StartApplication = async function startApplication(
};

if (__WEB__) {
startApplication((window as any)._default_sync_server, new BrowserBridge(__VERSION__));
startApplication(
(window as any)._default_sync_server,
new BrowserBridge(__VERSION__)
);
} else {
(window as any).startApplication = startApplication;
}

0 comments on commit cf76e1b

Please sign in to comment.