Skip to content

Commit

Permalink
network applet: keep visible networks under limit
Browse files Browse the repository at this point in the history
When adding a network, if we add it to a menu index <
NUM_VISIBLE_NETWORKS, if we now have > NUM_VISIBLE_NETWORKS networks, we
need to push the last visible network to being the first network in the
"more" menu.  Otherwise, we could end up with too many visible networks.

When updating a network position, we first removed it from the menu.
When doing this, if its original menu index was < NUM_VISIBLE_NETWORKS,
then we need to bump the first network in the "more" menu to being the
last visible network.  We now do this by now calling the already
existing _accessPointRemoved() method which handles this case.
Otherwise, we could end up with too few visible networks.
  • Loading branch information
jknockel committed Sep 27, 2024
1 parent 2d89551 commit bc8baf8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions files/usr/share/cinnamon/applets/network@cinnamon.org/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1385,8 +1385,7 @@ NMDeviceWireless.prototype = {
}

if (needsupdate) {
if (apObj.item)
apObj.item.destroy();
this._accessPointRemoved(device, accessPoint);

if (pos != -1)
this._networks.splice(pos, 1);
Expand All @@ -1413,6 +1412,19 @@ NMDeviceWireless.prototype = {

if (this._shouldShowConnectionList()) {
this._createNetworkItem(apObj, menuPos);
if (menuPos < NUM_VISIBLE_NETWORKS && this._networks.length > NUM_VISIBLE_NETWORKS) {
for (; menuPos < NUM_VISIBLE_NETWORKS; ++pos) {
if (this._networks[pos] != this._activeNetwork)
menuPos++;
}
let item = this._networks[pos].item;
if (item && item._apObj) {
item.destroy();
item._apObj.item = null;

this._createNetworkItem(item._apObj, NUM_VISIBLE_NETWORKS);
}
}
}
}
},
Expand Down

0 comments on commit bc8baf8

Please sign in to comment.