sort by last used in context menu

This commit is contained in:
Kyle Spearrin 2017-08-29 13:28:23 -04:00
parent 926e87c6fe
commit fcb7972fca
1 changed files with 15 additions and 0 deletions

View File

@ -586,6 +586,21 @@ function autofillPage() {
function sortLogins(logins) {
logins.sort(function (a, b) {
var lastUsedA = a.localData && a.localData.lastUsedDate ? a.localData.lastUsedDate : null;
var lastUsedB = b.localData && b.localData.lastUsedDate ? b.localData.lastUsedDate : null;
if (lastUsedA && lastUsedB && lastUsedA > lastUsedB) {
return -1;
}
if (lastUsedA && lastUsedB && lastUsedA < lastUsedB) {
return 1;
}
if (lastUsedA && !lastUsedB) {
return -1;
}
if (!lastUsedA && lastUsedB) {
return 1;
}
var nameA = (a.name + '_' + a.username).toUpperCase();
var nameB = (b.name + '_' + b.username).toUpperCase();