[gnome-shell] gdm: Keep messages in queue until we've not fully processed them
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] gdm: Keep messages in queue until we've not fully processed them
- Date: Tue, 16 Feb 2021 18:03:26 +0000 (UTC)
commit ef10bb6229ceb323822f27a436c5f3ce9ba12696
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Tue Feb 16 02:00:41 2021 +0100
gdm: Keep messages in queue until we've not fully processed them
It can be convenient to get the currently showing message in order to
replace or remove it in case it's not needed anymore.
So simplify the message queue handling by only depending on a single
local variable (_messageQueue) and redefining hasPendingMessages
depending on its content.
Now messages are kept in queue till they are not fully processed and the
first message is always the one currently shown.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1683>
js/gdm/util.js | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/js/gdm/util.js b/js/gdm/util.js
index 369c0bb331..16689f10e6 100644
--- a/js/gdm/util.js
+++ b/js/gdm/util.js
@@ -172,7 +172,6 @@ var ShellUserVerifier = class {
this._messageQueue = [];
this._messageQueueTimeoutId = 0;
- this.hasPendingMessages = false;
this.reauthenticating = false;
this._failCounter = 0;
@@ -194,10 +193,18 @@ var ShellUserVerifier = class {
}
}
+ get hasPendingMessages() {
+ return !!this._messageQueue.length;
+ }
+
get allowedFailures() {
return this._settings.get_int(ALLOWED_FAILURES_KEY);
}
+ get currentMessage() {
+ return this._messageQueue ? this._messageQueue[0] : null;
+ }
+
begin(userName, hold) {
this._cancellable = new Gio.Cancellable();
this._hold = hold;
@@ -283,7 +290,6 @@ var ShellUserVerifier = class {
this._messageQueue = [];
- this.hasPendingMessages = false;
this.emit('no-more-messages');
}
@@ -293,33 +299,33 @@ var ShellUserVerifier = class {
}
_queueMessageTimeout() {
- if (this._messageQueue.length == 0) {
- this.finishMessageQueue();
- return;
- }
-
if (this._messageQueueTimeoutId != 0)
return;
- let message = this._messageQueue.shift();
+ const message = this.currentMessage;
delete this._currentMessageExtraInterval;
this.emit('show-message', message.serviceName, message.text, message.type);
this._messageQueueTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
- message.interval + (this._currentMessageExtraInterval | 0),
- () => {
- this._messageQueueTimeoutId = 0;
- this._queueMessageTimeout();
- return GLib.SOURCE_REMOVE;
- });
+ message.interval + (this._currentMessageExtraInterval | 0), () => {
+ this._messageQueueTimeoutId = 0;
+
+ if (this._messageQueue.length > 1) {
+ this._messageQueue.shift();
+ this._queueMessageTimeout();
+ } else {
+ this.finishMessageQueue();
+ }
+
+ return GLib.SOURCE_REMOVE;
+ });
GLib.Source.set_name_by_id(this._messageQueueTimeoutId, '[gnome-shell] this._queueMessageTimeout');
}
_queueMessage(serviceName, message, messageType) {
let interval = this._getIntervalForMessage(message);
- this.hasPendingMessages = true;
this._messageQueue.push({ serviceName, text: message, type: messageType, interval });
this._queueMessageTimeout();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]