GUACAMOLE-724: Prefer to return an existing group rather than create a new one.

This ensures that focus state is maintained when switching from one
group to another. Focus state is otherwise reset when the group is
recreated.
This commit is contained in:
Michael Jumper
2021-07-04 18:58:53 -07:00
parent 74f0e0aec3
commit f6909a06e7

View File

@@ -235,6 +235,15 @@ angular.module('client').factory('guacClientManager', ['$injector',
*/ */
service.getManagedClientGroup = function getManagedClientGroup(id) { service.getManagedClientGroup = function getManagedClientGroup(id) {
var managedClientGroups = storedManagedClientGroups();
var existingGroup = _.find(managedClientGroups, (group) => {
return id === ManagedClientGroup.getIdentifier(group);
});
// Prefer to return the existing group if it exactly matches
if (existingGroup)
return existingGroup;
var clients = []; var clients = [];
var clientIds = ManagedClientGroup.getClientIdentifiers(id); var clientIds = ManagedClientGroup.getClientIdentifiers(id);
@@ -253,7 +262,6 @@ angular.module('client').factory('guacClientManager', ['$injector',
clients : clients clients : clients
}); });
var managedClientGroups = storedManagedClientGroups();
managedClientGroups.push(group); managedClientGroups.push(group);
return group; return group;