Skip to content
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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pmario
Copy link
Member

@pmario pmario commented Nov 12, 2017

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.

<$button class="tc-btn-big-green">
<$action-sendmessage $message="tm-save-wiki" $param="$:/editions/tw5.com/download-empty" filename="empty.html" backupdir="asdf" test={{test-test-test}}/> <---------- see filename, test and xxx
Download Empty {{$:/core/images/save-button}}
</$button>

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.

@pmario
Copy link
Member Author

pmario commented Nov 12, 2017

those changes should be completely backwards compatible, since they only add new functions params. The old signatures used are not changed.

@pmario
Copy link
Member Author

pmario commented Nov 12, 2017

@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.

@buggyj
Copy link
Contributor

buggyj commented Nov 12, 2017

@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);
Copy link
Member Author

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

Copy link
Member Author

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. ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buggyj

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

Copy link
Member Author

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 || {};
Copy link
Member Author

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);
Copy link
Member Author

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

@ght
Copy link

ght commented Mar 29, 2022

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).

@pmario
Copy link
Member Author

pmario commented Mar 29, 2022

The problem is, that the saverHandler is used by every saver, that works in a similar way as tiddlyfox did. .. So the problem still exists and should be solved some day. ... when I have time to dig out the code and make some docs, which is completely missing

@ght
Copy link

ght commented Mar 29, 2022

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.

@pmario pmario marked this pull request as draft March 29, 2022 15:58
@pmario
Copy link
Member Author

pmario commented Mar 29, 2022

I think, the main problem, why I did create this was the following behaviour.

  • Go to tiddlywiki.com
  • Set your browser "settings" -- save mechanism to "Always ask" before download.
  • Click the "Save changes" button ... to start the download process
  • The browser default "Save as" dialogue pops up ... and interrupts the save mechanism.
  • Look at the top right of the corner of the wiki. -- There was the "Saved wiki" TW notification
    • This notification is totally wrong, if the user clicks "cancel" in the browser dialogue.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TiddlyFox saver tiddlyfox.js doesn't pass on options received from saver-handler.js
3 participants