Closed buggyj closed 7 years ago
One solution would be to alway add a 'current saver attribute' and set to the name of the saver. Before any saving this attribute can be read, if it is not the same as set then don't do anything, except warn the user.
May be it is enough to check if the messagebox exists when installing (if it already exists then another extension has created it).
@pmario I have removed savetiddlers until this issue is resolved
I just had a closer look to the following functions
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/onInstalled and https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/connect
But imo there is no "safe" way to communicate, that can't be abused by others. ... So imo the message box ID seems to be the easiest way.
So the ContentScript can do the following:
// Inject the message box
var messageBox = doc.getElementById("tiddlyfox-message-box");
if (!messageBox) {
messageBox = doc.createElement("div");
messageBox.id = "tiddlyfox-message-box";
messageBox.setAttribute("data-tiddlyfox-creator", "<your-addon-name>")
messageBox.style.display = "none";
doc.body.appendChild(messageBox);
And if a new ContentScript is initialized, it can activate an info box. If the user doesn't resolve the problem, a "tm-save-wiki" will cause a new message box. ... And so on.
I was think of this:
// Inject the message box
var messageBox = doc.getElementById("tiddlyfox-message-box");
if(messageBox) {
var othersw = messageBox.getAttribute("data-message-box-creator")|| null;
if (othersw) {
alert ("as another tiddlysaver called "+othersw+" is install - savetiddlers is shutting down");
return;
} else {
messageBox.setAttribute("data-message-box-creator","savetiddlers");
} else {
messageBox = doc.createElement("div");
messageBox.id = "tiddlyfox-message-box";
messageBox.style.display = "none";
messageBox.setAttribute("data-message-box-creator","savetiddlers");
doc.body.appendChild(messageBox);
}
// Attach the event handler to the message box
messageBox.addEventListener("tiddlyfox-save-file",function(event) {
As we have return from the function no listener was installed so the extension does not react to requests
alert ("as another tiddlysaver called "+othersw+" is install - savetiddlers is shutting down");
I think the newly imported plugin should be more "self-confident" :)
"savetiddlers" has detected another plugin named: "xxxx".\n
At the moment only 1 "convenience save mecahnism" can be active at once.\n
We will temporarily deactivate the functionality, until the problem is resolved!
This message pops up till the user solves the problem. ...
But imo the main goal should be to make the convenience functions stackable.
yes may be better. As we seem to be in agreement I will make a new build with this code using "data-message-box-creator".
@pmario Unfortunately it is not possible to have two extensions both listening for messages from the TiddlyFoxSaver