diff --git a/js/components/contactList/contactList_controller.js b/js/components/contactList/contactList_controller.js index 9a1c9441b..b9fcb6bae 100644 --- a/js/components/contactList/contactList_controller.js +++ b/js/components/contactList/contactList_controller.js @@ -68,6 +68,11 @@ app.controller('contactlistCtrl', function($scope, $filter, $route, $routeParams ContactService.getAll().then(function(contacts) { $scope.$apply(function() { ctrl.contacts = contacts; + if (!_.isEmpty(ctrl.contacts)) { + ctrl.setSelectedId(_.sortBy(contacts, function(contact) { + return contact.fullName(); + })[0].uid()); + } ctrl.loading = false; }); }); @@ -105,6 +110,11 @@ app.controller('contactlistCtrl', function($scope, $filter, $route, $routeParams gid: $routeParams.gid, uid: ctrl.contactList[0].uid() }); + } else { + $route.updateParams({ + gid: $routeParams.gid, + uid: undefined + }); } unbindWatch(); // unbind as we only want one update }); diff --git a/templates/contactList.html b/templates/contactList.html index 9e2a44e27..e6af1f746 100644 --- a/templates/contactList.html +++ b/templates/contactList.html @@ -6,7 +6,7 @@ ng-click="setSelected(contact.uid())" ng-class="{active: contact.uid() === ctrl.getSelectedId()}"> -