From de097eaacf853c50d187676b62fda9ddc4066a21 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 30 Aug 2017 08:43:06 -0400 Subject: [PATCH] fix this reference to sort method --- src/services/loginService.js | 44 +++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/services/loginService.js b/src/services/loginService.js index 266b9fdeb0..07f2e6aaae 100644 --- a/src/services/loginService.js +++ b/src/services/loginService.js @@ -497,7 +497,28 @@ function initLoginService() { return deferred.promise; }; - LoginService.prototype.sortLoginsByLastUsed = function (a, b) { + LoginService.prototype.sortLoginsByLastUsed = sortLoginsByLastUsed; + + LoginService.prototype.sortLoginsByLastUsedThenName = function (a, b) { + var result = sortLoginsByLastUsed(a, b); + if (result !== 0) { + return result; + } + + var nameA = (a.name + '_' + a.username).toUpperCase(); + var nameB = (b.name + '_' + b.username).toUpperCase(); + + if (nameA < nameB) { + return -1; + } + if (nameA > nameB) { + return 1; + } + + return 0; + }; + + function sortLoginsByLastUsed(a ,b) { var aLastUsed = a.localData && a.localData.lastUsedDate ? a.localData.lastUsedDate : null; var bLastUsed = b.localData && b.localData.lastUsedDate ? b.localData.lastUsedDate : null; @@ -516,26 +537,7 @@ function initLoginService() { } return 0; - }; - - LoginService.prototype.sortLoginsByLastUsedThenName = function (a, b) { - var result = this.sortLoginsByLastUsed(a, b); - if (result !== 0) { - return result; - } - - var nameA = (a.name + '_' + a.username).toUpperCase(); - var nameB = (b.name + '_' + b.username).toUpperCase(); - - if (nameA < nameB) { - return -1; - } - if (nameA > nameB) { - return 1; - } - - return 0; - }; + } function handleError(error, deferred) { deferred.reject(error);