1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-13 18:15:48 +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(){
// no modals are visible
return false if $("#open-modal").is(":visible") || !$(".js-modals-container").is(":empty");
(function(){
var lastActivity = Date.now();
// all columns are in a default state
return false if $("section.js-column").is(".is-shifted-1,.is-shifted-2");
$(document).click(function(e){
lastActivity = Date.now();
});
// 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;
};
window.TDGF_tryRunCleanup = function(){
// no recent activity
return false if Date.now()-lastActivity < 15e3;
// no modals are visible
return false if $(".js-modal").is(":visible") || !$(".js-modals-container").is(":empty");
// all columns are in a default state
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){
var state;