GUACAMOLE-724: Restore sorting client panel by last used timestamp.

Sorting by last used (rather than relying on internal sorting) ensures
that the DOM is only modified as necessary and that CSS animations only
affect client groups that are newly visible in the panel.
This commit is contained in:
Michael Jumper
2021-07-04 19:04:04 -07:00
parent f6909a06e7
commit e5a127647b
3 changed files with 12 additions and 1 deletions

View File

@@ -307,6 +307,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
if (managedClientGroup) { if (managedClientGroup) {
$scope.clientGroup = managedClientGroup; $scope.clientGroup = managedClientGroup;
$scope.clientGroup.attached = true; $scope.clientGroup.attached = true;
$scope.clientGroup.lastUsed = new Date().getTime();
} }
}; };

View File

@@ -6,7 +6,7 @@
<!-- List of connection thumbnails --> <!-- List of connection thumbnails -->
<ul class="client-panel-connection-list"> <ul class="client-panel-connection-list">
<li ng-repeat="clientGroup in clientGroups" <li ng-repeat="clientGroup in clientGroups | orderBy: '-lastUsed'"
ng-if="!clientGroup.attached" ng-if="!clientGroup.attached"
ng-class="{ 'needs-attention' : hasStatusUpdate(clientGroup) }" ng-class="{ 'needs-attention' : hasStatusUpdate(clientGroup) }"
class="client-panel-connection"> class="client-panel-connection">

View File

@@ -38,6 +38,16 @@ angular.module('client').factory('ManagedClientGroup', ['$injector', function de
// Use empty object by default // Use empty object by default
template = template || {}; template = template || {};
/**
* The time that this group was last brought to the foreground of
* the current tab, as the number of milliseconds elapsed since
* midnight of January 1, 1970 UTC. If the group has not yet been
* viewed, this will be 0.
*
* @type Number
*/
this.lastUsed = template.lastUsed || 0;
/** /**
* Whether this ManagedClientGroup is currently attached to the client * Whether this ManagedClientGroup is currently attached to the client
* interface (true) or is running in the background (false). * interface (true) or is running in the background (false).