Properly wrap list action (#15)

This commit is contained in:
Erayd
2018-04-22 12:29:10 +12:00
committed by GitHub
parent 3d4fb25aab
commit bac6d640bf
2 changed files with 8 additions and 4 deletions

View File

@@ -175,7 +175,7 @@ async function handleMessage(settings, message, sendResponse) {
case "listFiles":
try {
var response = await hostAction(settings, "list");
sendResponse(response.data.files);
sendResponse({ status: "ok", files: response.data.files });
} catch (e) {
sendResponse({
status: "error",

View File

@@ -92,19 +92,23 @@ async function run(settings) {
try {
// get list of logins
var response = await chrome.runtime.sendMessage({ action: "listFiles" });
if (response.status != "ok") {
throw new Error(e);
}
var logins = [];
var index = 0;
var recent = localStorage.getItem("recent:" + settings.host);
if (recent) {
recent = JSON.parse(recent);
}
for (var store in response) {
for (var key in response[store]) {
for (var store in response.files) {
for (var key in response.files[store]) {
// set login fields
var login = {
index: index++,
store: settings.stores[store],
login: response[store][key].replace(/\.gpg$/i, ""),
login: response.files[store][key].replace(/\.gpg$/i, ""),
allowFill: true
};
login.domain = pathToDomain(store + "/" + login.login);