status/network: Make connectivity queue a Set

It's better suited than an array.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2406>
This commit is contained in:
Florian Müllner 2022-08-01 01:17:53 +02:00
parent ca2d39f6fb
commit de175dfca4

View File

@ -1759,7 +1759,7 @@ class Indicator extends PanelMenu.SystemIndicator {
this._activeConnections = []; this._activeConnections = [];
this._connections = []; this._connections = [];
this._connectivityQueue = []; this._connectivityQueue = new Set();
this._mainConnection = null; this._mainConnection = null;
@ -2090,23 +2090,14 @@ class Indicator extends PanelMenu.SystemIndicator {
} }
_flushConnectivityQueue() { _flushConnectivityQueue() {
if (this._portalHelperProxy) { for (let item of this._connectivityQueue)
for (let item of this._connectivityQueue) this._portalHelperProxy?.CloseAsync(item);
this._portalHelperProxy.CloseAsync(item).catch(logError); this._connectivityQueue.clear();
}
this._connectivityQueue = [];
} }
_closeConnectivityCheck(path) { _closeConnectivityCheck(path) {
let index = this._connectivityQueue.indexOf(path); if (this._connectivityQueue.delete(path))
this._portalHelperProxy?.CloseAsync(path);
if (index >= 0) {
if (this._portalHelperProxy)
this._portalHelperProxy.CloseAsync(path).catch(logError);
this._connectivityQueue.splice(index, 1);
}
} }
async _portalHelperDone(proxy, emitter, parameters) { async _portalHelperDone(proxy, emitter, parameters) {
@ -2149,10 +2140,8 @@ class Indicator extends PanelMenu.SystemIndicator {
return; return;
let path = this._mainConnection.get_path(); let path = this._mainConnection.get_path();
for (let item of this._connectivityQueue) { if (this._connectivityQueue.has(path))
if (item == path) return;
return;
}
let timestamp = global.get_current_time(); let timestamp = global.get_current_time();
if (!this._portalHelperProxy) { if (!this._portalHelperProxy) {
@ -2176,7 +2165,7 @@ class Indicator extends PanelMenu.SystemIndicator {
this._portalHelperProxy?.AuthenticateAsync(path, '', timestamp).catch(logError); this._portalHelperProxy?.AuthenticateAsync(path, '', timestamp).catch(logError);
this._connectivityQueue.push(path); this._connectivityQueue.add(path);
} }
_updateIcon() { _updateIcon() {