1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-17 12:15:47 +02:00

Make memory cleanup detect recent activity and fix modals

This commit is contained in:
chylex 2017-09-21 09:06:55 +02:00
parent 9f0997be1a
commit fd2cf5d4d7

View File

@ -1110,23 +1110,34 @@
}); });
}; };
window.TDGF_tryRunCleanup = function(){ (function(){
// no modals are visible var lastActivity = Date.now();
return false if $("#open-modal").is(":visible") || !$(".js-modals-container").is(":empty");
// all columns are in a default state $(document).click(function(e){
return false if $("section.js-column").is(".is-shifted-1,.is-shifted-2"); lastActivity = Date.now();
});
// all textareas are empty window.TDGF_tryRunCleanup = function(){
return false if Array.prototype.some.call(document.getElementsByTagName("textarea"), ele => ele.value.length > 0); // no recent activity
return false if Date.now()-lastActivity < 15e3;
// all columns are scrolled to top
return false if Array.prototype.some.call(document.getElementsByClassName("js-column-scroller"), ele => ele.scrollTop > 0); // no modals are visible
return false if $(".js-modal").is(":visible") || !$(".js-modals-container").is(":empty");
// cleanup
window.TDGF_reload(); // all columns are in a default state
return true; return false if $("section.js-column").is(".is-shifted-1,.is-shifted-2");
};
// all textareas are empty
return false if Array.prototype.some.call(document.getElementsByTagName("textarea"), ele => ele.value.length > 0);
// all columns are scrolled to top
return false if Array.prototype.some.call(document.getElementsByClassName("js-column-scroller"), ele => ele.scrollTop > 0);
// cleanup
window.TDGF_reload();
return true;
};
})();
if (window.TD_SESSION && window.TD_SESSION.gc){ if (window.TD_SESSION && window.TD_SESSION.gc){
var state; var state;