Only select nearest contact if not in the list

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2017-11-21 15:54:11 +01:00
parent 7f82451241
commit 1a41481649
No known key found for this signature in database
GPG Key ID: FB5ACEED51955BF8
1 changed files with 6 additions and 1 deletions

View File

@ -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;