network: Ensure the connection list is sorted after rename

Items were inserted correctly but the synchronisation was lost if the
name of a connection was changed. Simply making sure the position is
correct after a connection is updated fixes the issue.

Reported-by: Oliver Haessler <ohaessle@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=778686
This commit is contained in:
Benjamin Berg 2017-02-13 14:52:23 +01:00
parent c75785efff
commit 30e17036e8

View File

@ -299,11 +299,22 @@ const NMConnectionSection = new Lang.Class({
let item = this._connectionItems.get(connection.get_uuid());
if (item)
item.updateForConnection(connection);
this._updateForConnection(item, connection);
else
this._addConnection(connection);
},
_updateForConnection: function(item, connection) {
let pos = this._connections.indexOf(connection);
this._connections.splice(pos, 1);
pos = Util.insertSorted(this._connections, connection, Lang.bind(this, this._connectionSortFunction));
this._labelSection.moveMenuItem(item.labelItem, pos);
this._radioSection.moveMenuItem(item.radioItem, pos);
item.updateForConnection(connection);
},
_addConnection: function(connection) {
let item = this._makeConnectionItem(connection);
if (!item)