Scaffold: setInterval -> activate listener
This commit is contained in:
parent
a40ab83b71
commit
dea9fc5e88
1 changed files with 2 additions and 17 deletions
|
@ -57,7 +57,6 @@ var Scaffold = new function () {
|
|||
var _translatorsLoadedPromise;
|
||||
var _translatorProvider = null;
|
||||
var _lastModifiedTime = 0;
|
||||
var _lastHadFocus = true;
|
||||
|
||||
var _editors = {};
|
||||
|
||||
|
@ -147,22 +146,8 @@ var Scaffold = new function () {
|
|||
this.initCodeEditor();
|
||||
this.initTestsEditor();
|
||||
|
||||
// Listen for Scaffold coming to the foreground and reload translators.
|
||||
// We can't just set a focus listener on the <window> because it'll fire
|
||||
// when focus switches between the root window and any of the iframes.
|
||||
setInterval(() => {
|
||||
let hasFocus = document.hasFocus();
|
||||
if (_lastHadFocus == hasFocus) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasFocus) {
|
||||
this.reloadTranslators();
|
||||
}
|
||||
|
||||
_lastHadFocus = hasFocus;
|
||||
}, 1000);
|
||||
|
||||
// Listen for Scaffold coming to the foreground and reload translators
|
||||
window.addEventListener('activate', () => this.reloadTranslators());
|
||||
|
||||
Scaffold_Translators.setLoadListener({
|
||||
onLoadBegin: () => {
|
||||
|
|
Loading…
Reference in a new issue