-
Notifications
You must be signed in to change notification settings - Fork 29
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
Make userData bi-directional #71
Comments
So really what is needed is a bi-directional auxiliary transport of data between the config page and the app.js. We already do it one way with the Would also help to have an event fire just before the form is submitted available to the custom function |
Well with autoHandleEvents set to false there is already the getSettings method for retrieving the settings, but it still has to save its own copy of the settings locally on the phone since there is no default way of passing them back to the constructor. This could lead to passwords, etc being stored in cleartext and an app may not want the password being stored at all. From what I can tell, userData is made available to the custom function, but I was thinking of something that would disable the automatic saving of settings and accept a dictionary of values to restore settings on subsequent config page loads. So I was thinking of something more along the lines as below, which would not necessarily require a custom function:
|
So I'm not sure why the So in the custom function it would look something like: module.exports = function() {
var clayConfig = this;
clayConfig.on(clayConfig.EVENTS.BEFORE_SUBMIT, function() {
var password = clayConfig.getItemById('password').get();
clayConfig.meta.userData.password = password;
});
}; Then in your app.js: Pebble.addEventListener('webviewclosed', function(e) {
if (e && !e.response) {
return;
}
var password = clay.getUserData(e.response).password
someCleverThingWithThePassword(password);
// Get the keys and values from each config item
var dict = clay.getSettings(e.response);
// Send settings values to watch side
Pebble.sendAppMessage(dict, function(e) {
console.log('Sent config data to Pebble');
}, function(e) {
console.log('Failed to send config data!');
console.log(JSON.stringify(e));
});
});
|
OK, thanks. That gets the sensitive value from the config into the app.js presumably without Clay doing any auto-saving of the value, but what about the other way around for simplistic round-tripping of such values? |
you can set the meta.userData from the app,js as well. |
* pebble#71/bidirectional-user-data: Implemented bi-directional userData.
As I understand it, the framework autosaves the settings into localStorage and automatically reloads the values when subsequently displaying settings. For applications like where passwords need to be entered, I think it would be good to have an option where the application code handles saving settings so that, for example, a token could be stored instead of the password in plaintext when it isn't possible to do this with the custom function.
Could there be a constructor option to turn off autosave and pass the previous settings back to the config page manually so it could show the username and other settings, etc?
The text was updated successfully, but these errors were encountered: