mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-14 12:15:48 +02:00
Rewrite plugin reloading when enabled/disabled and refactor core plugin scripts
This commit is contained in:
parent
ca4d374a81
commit
564b4283b6
Resources
@ -238,7 +238,7 @@ enabled(){
|
||||
_render: () => $(this.htmlModal),
|
||||
destroy: function(){
|
||||
if (this.reloadPage){
|
||||
location.reload();
|
||||
window.TDPF_requestReload();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ enabled(){
|
||||
};
|
||||
|
||||
TD.decider.updateForGuestId();
|
||||
this.$pluginSettings.requiresPageReload = enable;
|
||||
this.$requiresReload = enable;
|
||||
};
|
||||
|
||||
// animation optimization
|
||||
|
@ -1,12 +1,14 @@
|
||||
(function(){
|
||||
var isReloading = false;
|
||||
|
||||
//
|
||||
// Class: Abstract plugin base class.
|
||||
//
|
||||
window.PluginBase = class{
|
||||
constructor(pluginSettings){
|
||||
this.$pluginSettings = pluginSettings || {};
|
||||
this.$requiresReload = !!(pluginSettings && pluginSettings.requiresPageReload);
|
||||
}
|
||||
|
||||
|
||||
enabled(){}
|
||||
ready(){}
|
||||
disabled(){}
|
||||
@ -49,11 +51,11 @@
|
||||
}
|
||||
|
||||
setState(plugin, enable){
|
||||
let reloading = plugin.obj.$pluginSettings.requiresPageReload;
|
||||
let reloading = plugin.obj.$requiresReload;
|
||||
|
||||
if (enable && this.isDisabled(plugin)){
|
||||
if (reloading){
|
||||
location.reload();
|
||||
window.TDPF_requestReload();
|
||||
}
|
||||
else{
|
||||
this.disabled.splice(this.disabled.indexOf(plugin.id), 1);
|
||||
@ -63,7 +65,7 @@
|
||||
}
|
||||
else if (!enable && !this.isDisabled(plugin)){
|
||||
if (reloading){
|
||||
location.reload();
|
||||
window.TDPF_requestReload();
|
||||
}
|
||||
else{
|
||||
this.disabled.push(plugin.id);
|
||||
@ -84,4 +86,14 @@
|
||||
window.TDPF_setPluginState = function(identifier, enable){
|
||||
window.TD_PLUGINS.setState(window.TD_PLUGINS.findObject(identifier), enable);
|
||||
};
|
||||
})();
|
||||
|
||||
//
|
||||
// Block: Setup global function to reload the page.
|
||||
//
|
||||
window.TDPF_requestReload = function(){
|
||||
if (!isReloading){
|
||||
window.setTimeout(() => location.reload(), 1);
|
||||
isReloading = true;
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
@ -51,4 +51,4 @@
|
||||
obj.element = element;
|
||||
return obj;
|
||||
};
|
||||
})($TDP);
|
||||
})($TDP);
|
||||
|
@ -1,21 +1,16 @@
|
||||
(function(){
|
||||
//
|
||||
// Class: Abstract plugin base class.
|
||||
//
|
||||
window.PluginBase = class{
|
||||
constructor(pluginSettings){
|
||||
this.$pluginSettings = pluginSettings || {};
|
||||
}
|
||||
//
|
||||
// Class: Abstract plugin base class.
|
||||
//
|
||||
window.PluginBase = class{
|
||||
constructor(){}
|
||||
run(){}
|
||||
};
|
||||
|
||||
run(){}
|
||||
};
|
||||
|
||||
//
|
||||
// Variable: Main object for containing and managing plugins.
|
||||
//
|
||||
window.TD_PLUGINS = {
|
||||
install: function(plugin){
|
||||
plugin.obj.run();
|
||||
}
|
||||
};
|
||||
})();
|
||||
//
|
||||
// Variable: Main object for containing and managing plugins.
|
||||
//
|
||||
window.TD_PLUGINS = {
|
||||
install: function(plugin){
|
||||
plugin.obj.run();
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user