[gnome-shell] gdm: Filter service non-error messages on verification stopped or failed



commit 45a5171a95c7337a541c765306b5e5fd7f790de3
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Tue Feb 16 03:45:14 2021 +0100

    gdm: Filter service non-error messages on verification stopped or failed
    
    Once the verification has been stopped or has failed all the messages
    that are not of error type are just not needed or wrong to show.
    For example, in the fingerprint case we may still show the hint to swipe
    or touch the device, while the fingerprint PAM service has already been
    stopped.
    
    So filter them by adding a new function that adds a null message to the
    queue, overriding all the messages that have a lower priority.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1683>

 js/gdm/util.js | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/js/gdm/util.js b/js/gdm/util.js
index 67255bc9e2..f1c3c91497 100644
--- a/js/gdm/util.js
+++ b/js/gdm/util.js
@@ -281,6 +281,9 @@ var ShellUserVerifier = class {
     }
 
     _getIntervalForMessage(message) {
+        if (!message)
+            return 0;
+
         // We probably could be smarter here
         return message.length * USER_READ_TIME;
     }
@@ -299,6 +302,18 @@ var ShellUserVerifier = class {
             this._currentMessageExtraInterval = interval;
     }
 
+    _serviceHasPendingMessages(serviceName) {
+        return this._messageQueue.some(m => m.serviceName === serviceName);
+    }
+
+    _filterServiceMessages(serviceName, messageType) {
+        // This function allows to remove queued messages for the @serviceName
+        // whose type has lower priority than @messageType, replacing them
+        // with a null message that will lead to clearing the prompt once done.
+        if (this._serviceHasPendingMessages(serviceName))
+            this._queuePriorityMessage(serviceName, null, messageType);
+    }
+
     _queueMessageTimeout() {
         if (this._messageQueueTimeoutId != 0)
             return;
@@ -678,6 +693,7 @@ var ShellUserVerifier = class {
         const canRetry = retry && this._canRetry();
 
         this._disconnectSignals();
+        this._filterServiceMessages(serviceName, MessageType.ERROR);
 
         if (canRetry) {
             if (!this.hasPendingMessages) {
@@ -730,6 +746,8 @@ var ShellUserVerifier = class {
             return;
         }
 
+        this._filterServiceMessages(serviceName, MessageType.ERROR);
+
         if (this._unavailableServices.has(serviceName))
             return;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]