1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-08 09:32:07 +01:00

A few fixes and optimizations

This commit is contained in:
Kyle Spearrin 2016-12-30 14:50:16 -05:00
parent 2310f5ebdf
commit cd4ef192f6

View File

@ -360,7 +360,7 @@ function addLogin(login, tab) {
siteService.getAllDecryptedForDomain(loginDomain).then(function (sites) { siteService.getAllDecryptedForDomain(loginDomain).then(function (sites) {
var match = false; var match = false;
for (var i = 0; i < sites.length; i++) { for (var i = 0; i < sites.length; i++) {
if (sites[i] === login.username) { if (sites[i].username === login.username) {
match = true; match = true;
break; break;
} }
@ -378,7 +378,7 @@ function addLogin(login, tab) {
tabId: tab.id, tabId: tab.id,
expires: new Date((new Date()).getTime() + 30 * 60000) // 30 minutes expires: new Date((new Date()).getTime() + 30 * 60000) // 30 minutes
}); });
checkLoginsToAdd(); checkLoginsToAdd(tab);
} }
}); });
} }
@ -430,36 +430,41 @@ function saveAddLogin(tab) {
} }
} }
function checkLoginsToAdd() { function checkLoginsToAdd(tab) {
if (!loginsToAdd.length) { if (!loginsToAdd.length) {
return; return;
} }
if (tab) {
check();
return;
}
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var tabId = null;
if (tabs.length > 0) { if (tabs.length > 0) {
tabId = tabs[0].id; tab = tabs[0];
check();
} }
else { });
function check() {
if (!tab) {
return; return;
} }
if (!tabId) { var tabDomain = tldjs.getDomain(tab.url);
return;
}
var tabDomain = tldjs.getDomain(tabs[0].url);
if (!tabDomain) { if (!tabDomain) {
return; return;
} }
for (var i = 0; i < loginsToAdd.length; i++) { for (var i = 0; i < loginsToAdd.length; i++) {
if (loginsToAdd[i].tabId === tabId && loginsToAdd[i].name === tabDomain) { // loginsToAdd[x].name is the domain here
messageTab(tabId, 'openNotificationBar', { type: 'add' }); if (loginsToAdd[i].tabId === tab.id && loginsToAdd[i].name === tabDomain) {
messageTab(tab.id, 'openNotificationBar', { type: 'add' });
break; break;
} }
} }
}); }
} }
function startAutofillPage(site) { function startAutofillPage(site) {