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>
This commit is contained in:
parent
9ecc1a4cd7
commit
ef10bb6229
@ -172,7 +172,6 @@ var ShellUserVerifier = class {
|
|||||||
|
|
||||||
this._messageQueue = [];
|
this._messageQueue = [];
|
||||||
this._messageQueueTimeoutId = 0;
|
this._messageQueueTimeoutId = 0;
|
||||||
this.hasPendingMessages = false;
|
|
||||||
this.reauthenticating = false;
|
this.reauthenticating = false;
|
||||||
|
|
||||||
this._failCounter = 0;
|
this._failCounter = 0;
|
||||||
@ -194,10 +193,18 @@ var ShellUserVerifier = class {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get hasPendingMessages() {
|
||||||
|
return !!this._messageQueue.length;
|
||||||
|
}
|
||||||
|
|
||||||
get allowedFailures() {
|
get allowedFailures() {
|
||||||
return this._settings.get_int(ALLOWED_FAILURES_KEY);
|
return this._settings.get_int(ALLOWED_FAILURES_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get currentMessage() {
|
||||||
|
return this._messageQueue ? this._messageQueue[0] : null;
|
||||||
|
}
|
||||||
|
|
||||||
begin(userName, hold) {
|
begin(userName, hold) {
|
||||||
this._cancellable = new Gio.Cancellable();
|
this._cancellable = new Gio.Cancellable();
|
||||||
this._hold = hold;
|
this._hold = hold;
|
||||||
@ -283,7 +290,6 @@ var ShellUserVerifier = class {
|
|||||||
|
|
||||||
this._messageQueue = [];
|
this._messageQueue = [];
|
||||||
|
|
||||||
this.hasPendingMessages = false;
|
|
||||||
this.emit('no-more-messages');
|
this.emit('no-more-messages');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,33 +299,33 @@ var ShellUserVerifier = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_queueMessageTimeout() {
|
_queueMessageTimeout() {
|
||||||
if (this._messageQueue.length == 0) {
|
|
||||||
this.finishMessageQueue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._messageQueueTimeoutId != 0)
|
if (this._messageQueueTimeoutId != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let message = this._messageQueue.shift();
|
const message = this.currentMessage;
|
||||||
|
|
||||||
delete this._currentMessageExtraInterval;
|
delete this._currentMessageExtraInterval;
|
||||||
this.emit('show-message', message.serviceName, message.text, message.type);
|
this.emit('show-message', message.serviceName, message.text, message.type);
|
||||||
|
|
||||||
this._messageQueueTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
|
this._messageQueueTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
|
||||||
message.interval + (this._currentMessageExtraInterval | 0),
|
message.interval + (this._currentMessageExtraInterval | 0), () => {
|
||||||
() => {
|
this._messageQueueTimeoutId = 0;
|
||||||
this._messageQueueTimeoutId = 0;
|
|
||||||
this._queueMessageTimeout();
|
if (this._messageQueue.length > 1) {
|
||||||
return GLib.SOURCE_REMOVE;
|
this._messageQueue.shift();
|
||||||
});
|
this._queueMessageTimeout();
|
||||||
|
} else {
|
||||||
|
this.finishMessageQueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
return GLib.SOURCE_REMOVE;
|
||||||
|
});
|
||||||
GLib.Source.set_name_by_id(this._messageQueueTimeoutId, '[gnome-shell] this._queueMessageTimeout');
|
GLib.Source.set_name_by_id(this._messageQueueTimeoutId, '[gnome-shell] this._queueMessageTimeout');
|
||||||
}
|
}
|
||||||
|
|
||||||
_queueMessage(serviceName, message, messageType) {
|
_queueMessage(serviceName, message, messageType) {
|
||||||
let interval = this._getIntervalForMessage(message);
|
let interval = this._getIntervalForMessage(message);
|
||||||
|
|
||||||
this.hasPendingMessages = true;
|
|
||||||
this._messageQueue.push({ serviceName, text: message, type: messageType, interval });
|
this._messageQueue.push({ serviceName, text: message, type: messageType, interval });
|
||||||
this._queueMessageTimeout();
|
this._queueMessageTimeout();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user