Skip to content

Commit

Permalink
accounts-ui: don't display message twice
Browse files Browse the repository at this point in the history
  • Loading branch information
avital committed Nov 20, 2012
1 parent 738e8f4 commit 59bab69
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions packages/accounts-ui-unstyled/login_buttons_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'errorMessage',
'infoMessage',

// dialogs with messages (info and error)
'resetPasswordToken',
'enrollAccountToken',
'justVerifiedEmail',
Expand Down Expand Up @@ -58,17 +59,33 @@
infoMessage: function(message) {
this._set("errorMessage", null);
this._set("infoMessage", message);
this.set("dropdownVisible", true); // See #OpenDropdownForMessage
this.ensureMessageVisible();
},

errorMessage: function(message) {
this._set("errorMessage", message);
this._set("infoMessage", null);
this.ensureMessageVisible();
},

// is there a visible dialog that shows messages (info and error)
isMessageDialogVisible: function () {
return this.get('resetPasswordToken') ||
this.get('enrollAccountToken') ||
this.get('justVerifiedEmail');
},

// #OpenDropdownForMessage
// for the case that you're taking some action in the dropdown, and then you
// get an error or message. notably has no effect in the single button case.
this.set("dropdownVisible", true);
// ensure that somethings displaying a message (info or error) is
// visible. if a dialog with messages is open, do nothing;
// otherwise open the dropdown.
//
// notably this doesn't matter when only displaying a single login
// button since then we have an explicit message dialog
// (_loginButtonsMessageDialog), and dropdownVisible is ignored in
// this case.
ensureMessageVisible: function () {
if (!this.isMessageDialogVisible())
this.set("dropdownVisible", true);
},

resetMessages: function () {
Expand Down

0 comments on commit 59bab69

Please sign in to comment.