[gnome-shell/wip/wayland-gdm-cleanup: 7/19] gdm: Clean up pending messages handling
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/wayland-gdm-cleanup: 7/19] gdm: Clean up pending messages handling
- Date: Sat, 8 Mar 2014 00:25:51 +0000 (UTC)
commit ebef4ff17456f3b148c26b5a23def63adac170c5
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Mar 7 15:59:21 2014 -0500
gdm: Clean up pending messages handling
Introduce a new doAfterPendingMessages helper to wait until
we have no more pending messages before doing an action.
js/gdm/util.js | 44 +++++++++++++++++---------------------------
1 files changed, 17 insertions(+), 27 deletions(-)
---
diff --git a/js/gdm/util.js b/js/gdm/util.js
index 9b23f0c..d4649f0 100644
--- a/js/gdm/util.js
+++ b/js/gdm/util.js
@@ -205,18 +205,23 @@ const ShellUserVerifier = new Lang.Class({
this._clearMessageQueue();
},
- answerQuery: function(serviceName, answer) {
- if (!this.hasPendingMessages) {
- this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
+ _doAfterPendingMessages: function(func) {
+ if (this.hasPendingMessages) {
+ let signalId = this.connect('no-more-messages', Lang.bind(this, function() {
+ this.disconnect(signalId);
+ func();
+ }));
} else {
- let signalId = this.connect('no-more-messages',
- Lang.bind(this, function() {
- this.disconnect(signalId);
- this._userVerifier.call_answer_query(serviceName, answer,
this._cancellable, null);
- }));
+ func();
}
},
+ answerQuery: function(serviceName, answer) {
+ this._doAfterPendingMessages(Lang.bind(this, function() {
+ this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
+ }));
+ },
+
_getIntervalForMessage: function(message) {
// We probably could be smarter here
return message.length * USER_READ_TIME;
@@ -503,27 +508,12 @@ const ShellUserVerifier = new Lang.Class({
this.emit('verification-failed');
- if (canRetry) {
- if (!this.hasPendingMessages) {
+ this._doAfterPendingMessages(Lang.bind(this, function() {
+ if (canRetry)
this._retry();
- } else {
- let signalId = this.connect('no-more-messages',
- Lang.bind(this, function() {
- this.disconnect(signalId);
- this._retry();
- }));
- }
- } else {
- if (!this.hasPendingMessages) {
+ else
this.cancel();
- } else {
- let signalId = this.connect('no-more-messages',
- Lang.bind(this, function() {
- this.disconnect(signalId);
- this.cancel();
- }));
- }
- }
+ }));
},
_onConversationStopped: function(client, serviceName) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]