status/network: Fix name of initially hidden devices
We assign (disambiguated) device names every time a device is added or removed, and store the name on the corresponding menu item. However menu items are only created when the device should be shown, not necessarily when it is added (unplugged ethernet cable, ongoing initialization, ...). Fix this by tracking device names separately from device items, and set the name on newly created items. https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6040 Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2529>
This commit is contained in:
parent
a33e3eaf22
commit
b2ff25b31d
@ -1559,6 +1559,7 @@ class NMDeviceToggle extends NMToggle {
|
|||||||
|
|
||||||
this._deviceType = deviceType;
|
this._deviceType = deviceType;
|
||||||
this._nmDevices = new Set();
|
this._nmDevices = new Set();
|
||||||
|
this._deviceNames = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
setClient(client) {
|
setClient(client) {
|
||||||
@ -1613,8 +1614,12 @@ class NMDeviceToggle extends NMToggle {
|
|||||||
_syncDeviceNames() {
|
_syncDeviceNames() {
|
||||||
const devices = [...this._nmDevices];
|
const devices = [...this._nmDevices];
|
||||||
const names = NM.Device.disambiguate_names(devices);
|
const names = NM.Device.disambiguate_names(devices);
|
||||||
|
this._deviceNames.clear();
|
||||||
devices.forEach(
|
devices.forEach(
|
||||||
(dev, i) => this._items.get(dev)?.setDeviceName(names[i]));
|
(dev, i) => {
|
||||||
|
this._deviceNames.set(dev, names[i]);
|
||||||
|
this._items.get(dev)?.setDeviceName(names[i]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_syncDeviceItem(device) {
|
_syncDeviceItem(device) {
|
||||||
@ -1647,6 +1652,7 @@ class NMDeviceToggle extends NMToggle {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const item = this._createDeviceMenuItem(device);
|
const item = this._createDeviceMenuItem(device);
|
||||||
|
item.setDeviceName(this._deviceNames.get(device) ?? '');
|
||||||
this._addItem(device, item);
|
this._addItem(device, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user