-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2 way communication between contentScript and tiddlyfox.js #3010
base: master
Are you sure you want to change the base?
Conversation
those changes should be completely backwards compatible, since they only add new functions params. The old signatures used are not changed. |
@buggyj ... These changes should be also usefull for you and the "savetiddlers" addOn. ... It's intended as a "progressive enhancement" ... So no need to use it, but can be usefull for future plugin enhancements. Eg: "backupdir" can be defined with the TW UI. So every TW can store its own setting. ... No need to keep stuff in the browser "crap-stores", that are out of sync anyway. |
@pmario looks good. One issue is the saver always returning null - (indicating success) there is noway to indicate failure. |
callback(null); | ||
// callback(err,response) | ||
// response is a response Object {} after a succsessfull save. | ||
callback(null,message.dataset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this info goes to save-handler as saverInfo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message.dataset
is defined by browser addOn "ContentScripts" as date-tiddlyfox-XXXX
elements.
This mechanism enables a 2 way communication between the TW user and browser addOns, without the need to implement OS notifications. ... So we can stay with the built in TW notify messages. ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue is the saver always returning null - (indicating success) there is noway to indicate failure.
Yea, ... but I didn't change this code. This path was obviously the "no error" state.
the saverInfo
can contain whatever is needed. ... So if an error shoudl be shown it needs to be there and implemented like this in a plugin. + the callback function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmmm, .... but you are right. ... It shows the "saved" notification first and then an error. .. So we may change it.
// SaverInfo is an Object, that contains info definde by the saver. eg: tiddlyfox.js | ||
// as a return value after a successfull write action. | ||
callback = function(err,saverInfo) { | ||
saverInfo = saverInfo || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comes from custom saver eg: tiddlyfox.js
@@ -160,7 +164,7 @@ SaverHandler.prototype.saveWiki = function(options) { | |||
} | |||
$tw.notifier.display(self.titleSavedNotification); | |||
if(options.callback) { | |||
options.callback(); | |||
options.callback(saverInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this callback function is not active at the moment, since tm-save-wiki
and tm-download-file
don't implement callbacks at the moment.
If this code branch should be used, plugins just need to overwrite the existing mechanisms, or create new ones. eg: "tm-save-wiki-and-open-user-dialog" .... or whatever is needed by the custom saver
This can be closed. TiddlyFox is not working since Firefox v57, released 2017-11-14 and the addon no longer available (old link, now dead). |
The problem is, that the |
Hm I see. Could you please make an issue for that which describes the problem clearly? The related issue for this (#3004) is a bit vague and I'm struggling to grasp the issue, as I'm still quite new to the code internals. The new issue can link to this and to the mentioned issue for context, but I'd argue both can be closed then, since they are specific to the obsolete TiddlyFox and not the general issue you mentioned. |
I think, the main problem, why I did create this was the following behaviour.
Since for this dialogue, it is more of an annoyance, than a real problem I didn't force it. It can be a problem for plugin creators. |
Work in progress - Don't merge atm!
fixes #3004 "TiddlyFox saver tiddlyfox.js doesn't pass on options received from saver-handler.js"
See detailed comments in the code. ... The changes implemented here allow custom savers eg: tiddlyfox.js and others to get info from TW config UI.
The above button creates a custom "save-wiki" button, that allows users to define eg: "backupdir", which can then be used by custom saver modules and browser addOns.