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": case "listFiles":
try { try {
var response = await hostAction(settings, "list"); var response = await hostAction(settings, "list");
sendResponse(response.data.files); sendResponse({ status: "ok", files: response.data.files });
} catch (e) { } catch (e) {
sendResponse({ sendResponse({
status: "error", status: "error",

View File

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