mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-18 06:15:49 +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),
|
_render: () => $(this.htmlModal),
|
||||||
destroy: function(){
|
destroy: function(){
|
||||||
if (this.reloadPage){
|
if (this.reloadPage){
|
||||||
location.reload();
|
window.TDPF_requestReload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ enabled(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
TD.decider.updateForGuestId();
|
TD.decider.updateForGuestId();
|
||||||
this.$pluginSettings.requiresPageReload = enable;
|
this.$requiresReload = enable;
|
||||||
};
|
};
|
||||||
|
|
||||||
// animation optimization
|
// animation optimization
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
(function(){
|
(function(){
|
||||||
|
var isReloading = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Class: Abstract plugin base class.
|
// Class: Abstract plugin base class.
|
||||||
//
|
//
|
||||||
window.PluginBase = class{
|
window.PluginBase = class{
|
||||||
constructor(pluginSettings){
|
constructor(pluginSettings){
|
||||||
this.$pluginSettings = pluginSettings || {};
|
this.$requiresReload = !!(pluginSettings && pluginSettings.requiresPageReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled(){}
|
enabled(){}
|
||||||
ready(){}
|
ready(){}
|
||||||
disabled(){}
|
disabled(){}
|
||||||
@ -49,11 +51,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
setState(plugin, enable){
|
setState(plugin, enable){
|
||||||
let reloading = plugin.obj.$pluginSettings.requiresPageReload;
|
let reloading = plugin.obj.$requiresReload;
|
||||||
|
|
||||||
if (enable && this.isDisabled(plugin)){
|
if (enable && this.isDisabled(plugin)){
|
||||||
if (reloading){
|
if (reloading){
|
||||||
location.reload();
|
window.TDPF_requestReload();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.disabled.splice(this.disabled.indexOf(plugin.id), 1);
|
this.disabled.splice(this.disabled.indexOf(plugin.id), 1);
|
||||||
@ -63,7 +65,7 @@
|
|||||||
}
|
}
|
||||||
else if (!enable && !this.isDisabled(plugin)){
|
else if (!enable && !this.isDisabled(plugin)){
|
||||||
if (reloading){
|
if (reloading){
|
||||||
location.reload();
|
window.TDPF_requestReload();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.disabled.push(plugin.id);
|
this.disabled.push(plugin.id);
|
||||||
@ -84,4 +86,14 @@
|
|||||||
window.TDPF_setPluginState = function(identifier, enable){
|
window.TDPF_setPluginState = function(identifier, enable){
|
||||||
window.TD_PLUGINS.setState(window.TD_PLUGINS.findObject(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;
|
obj.element = element;
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
})($TDP);
|
})($TDP);
|
||||||
|
@ -1,21 +1,16 @@
|
|||||||
(function(){
|
//
|
||||||
//
|
// Class: Abstract plugin base class.
|
||||||
// Class: Abstract plugin base class.
|
//
|
||||||
//
|
window.PluginBase = class{
|
||||||
window.PluginBase = class{
|
constructor(){}
|
||||||
constructor(pluginSettings){
|
run(){}
|
||||||
this.$pluginSettings = pluginSettings || {};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
run(){}
|
//
|
||||||
};
|
// Variable: Main object for containing and managing plugins.
|
||||||
|
//
|
||||||
//
|
window.TD_PLUGINS = {
|
||||||
// Variable: Main object for containing and managing plugins.
|
install: function(plugin){
|
||||||
//
|
plugin.obj.run();
|
||||||
window.TD_PLUGINS = {
|
}
|
||||||
install: function(plugin){
|
};
|
||||||
plugin.obj.run();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
Loading…
Reference in New Issue
Block a user