Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
Closes gh-27: Using "generate password" more than once when creating...
Browse files Browse the repository at this point in the history
    * app/assistants/item-assistant.js (setGeneratedPassword): Call
    fieldUpdated() instead of ring.updateItem() to ensure that bookkeeping
    is kept in order.
    (timeoutOrDeactivate): Wrap call to ring.updateItem() in try/catch so
    that we'll still get to lockout even if that fails.
  • Loading branch information
Dirk Bergstrom committed Apr 22, 2010
1 parent 00acd9d commit 1c390ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 7 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ Closes gh-8: Categories should (optionally?) sort in alpha order
(ItemListAssistant): Initialize this.category to ring.prefs.category
to avoid extra work on activate().

* app/assistants/item-assistant.js (setup): Adjust to new signature of
ring.categoriesForMojo();
Closes gh-27: Using "generate password" more than once when creating...
* app/assistants/item-assistant.js (setGeneratedPassword): Call
fieldUpdated() instead of ring.updateItem() to ensure that bookkeeping
is kept in order.
(timeoutOrDeactivate): Wrap call to ring.updateItem() in try/catch so
that we'll still get to lockout even if that fails.
(setup): Adjust to new signature of ring.categoriesForMojo();

* app/assistants/categories-assistant.js (categoryAdded): Update to handle
alpha sorted categories list.
Expand Down
12 changes: 9 additions & 3 deletions app/assistants/item-assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,11 @@ ItemAssistant.prototype.cancel = function() {

/* Callback for handling generated passwords. */
ItemAssistant.prototype.setGeneratedPassword = function(password) {
Mojo.Log.info("setGenerated", password);
Mojo.Log.info("setGenerated");
this.item.pass = password;
this.controller.modelChanged(this.item);
this.ring.updateItem(this.titleInDatabase, this.item);
// Send a fake event to fieldUpdated()
this.fieldUpdated({'property': 'password', 'value': password});
};

/* Callback to set title for new item creation. */
Expand Down Expand Up @@ -303,7 +304,12 @@ ItemAssistant.prototype.timeoutOrDeactivate = function(event) {
}, this);
if (dirty) {
Mojo.Log.info("Found dirty field after timeout, saving");
this.ring.updateItem(this.titleInDatabase, this.item);
try {
this.ring.updateItem(this.titleInDatabase, this.item);
}
catch (err) {
Mojo.Log.info("Error saving item on timeout: " + err);
}
}
this.timedOut = true;
if (! (event && event.type === "mojo-stage-deactivate")) {
Expand Down

0 comments on commit 1c390ec

Please sign in to comment.