1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

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

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();