diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2017-11-21 15:54:11 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2017-11-21 16:00:06 +0100 |
commit | 1a4148164931ab7defe3f5b016c048da2eacd799 (patch) | |
tree | 7c9e75948a7940fb415ba207abea391287e240d2 /js | |
parent | 7f82451241829e70d50eaccfc38ed3f2d48fd171 (diff) |
Only select nearest contact if not in the list
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'js')
-rw-r--r-- | js/components/contactList/contactList_controller.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/js/components/contactList/contactList_controller.js b/js/components/contactList/contactList_controller.js index 1e09c179..f13bf76e 100644 --- a/js/components/contactList/contactList_controller.js +++ b/js/components/contactList/contactList_controller.js @@ -104,7 +104,12 @@ angular.module('contactsApp') ContactService.getAll().then(function(contacts) { ctrl.contactList = contacts; ctrl.loading = false; - ctrl.selectNearestContact(ctrl.getSelectedId()); + // Only change contact if the selectd one is not in the list anymore + if(ctrl.contactList.findIndex(function(contact) { + return contact.uid() === ctrl.getSelectedId(); + }) === -1) { + ctrl.selectNearestContact(ctrl.getSelectedId()); + } }); }); break; |