Fix RPC data

pull/1/head
yflory 5 years ago
parent 906b315487
commit 3d1b3b5d18

@ -1735,14 +1735,14 @@ define([
hash: hash, hash: hash,
teamId: config.teamId, teamId: config.teamId,
seeds: seeds, seeds: seeds,
}, waitFor(function (error) { }, waitFor(function (obj) {
if (error) { if (obj && obj.error) {
waitFor.abort(); waitFor.abort();
$(linkSpin).hide(); $(linkSpin).hide();
$(linkForm).show(); // XXX DB: check this is the right place to put things back $(linkForm).show(); // XXX DB: check this is the right place to put things back
$nav.find('button.cp-teams-invite-create').show(); $nav.find('button.cp-teams-invite-create').show();
$nav.find('button.cp-teams-invite-copy').hide(); $nav.find('button.cp-teams-invite-copy').hide();
return void $(linkError).text(Messages.team_inviteLinkError+error).show(); // XXX return void $(linkError).text(Messages.team_inviteLinkError+obj.error).show(); // XXX
} }
// Display result here // Display result here
$(linkSpin).hide(); $(linkSpin).hide();

@ -1285,7 +1285,7 @@ define([
try { try {
teamName = roster.getState().metadata.name; teamName = roster.getState().metadata.name;
} catch (err) { } catch (err) {
return void cb("TEAM_NAME_ERR"); return void cb({ error: "TEAM_NAME_ERR" });
} }
var message = data.message; var message = data.message;
@ -1342,7 +1342,7 @@ define([
if (err) { if (err) {
console.error("CRYPTPUT_ERR", err); console.error("CRYPTPUT_ERR", err);
w.abort(); w.abort();
return void cb("SET_PREVIEW_CONTENT"); return void cb({ error: "SET_PREVIEW_CONTENT" });
} }
}), putOpts); }), putOpts);
}()); }());
@ -1378,7 +1378,7 @@ define([
if (err) { if (err) {
console.error("CRYPTPUT_ERR", err); console.error("CRYPTPUT_ERR", err);
w.abort(); w.abort();
return void cb("SET_PREVIEW_CONTENT"); return void cb({ error: "SET_PREVIEW_CONTENT" });
} }
}), putOpts); }), putOpts);
}()); }());
@ -1419,7 +1419,7 @@ define([
try { try {
previewKeys = Invite.derivePreviewKeys(seeds.preview); previewKeys = Invite.derivePreviewKeys(seeds.preview);
} catch (err) { } catch (err) {
return void cb("INVALID_SEEDS"); return void cb({ error: "INVALID_SEEDS" });
} }
Crypt.get({ // secrets Crypt.get({ // secrets
channel: previewKeys.channel, channel: previewKeys.channel,
@ -1429,13 +1429,13 @@ define([
cryptKey: previewKeys.cryptKey, cryptKey: previewKeys.cryptKey,
}, },
}, function (err, val) { }, function (err, val) {
if (err) { return void cb(err); } if (err) { return void cb({ error: err }); }
if (!val) { return void cb('DELETED'); } if (!val) { return void cb({ error: 'DELETED' }); }
var json = Util.tryParse(val); var json = Util.tryParse(val);
if (!json) { return void cb("parseError"); } if (!json) { return void cb({ error: "parseError" }); }
console.error("JSON", json); console.error("JSON", json);
cb(void 0, json); cb(json);
}, { // cryptget opts }, { // cryptget opts
network: ctx.store.network, network: ctx.store.network,
initialState: '{}', initialState: '{}',
@ -1448,7 +1448,7 @@ define([
try { try {
previewKeys = Invite.deriveInviteKeys(bytes64); previewKeys = Invite.deriveInviteKeys(bytes64);
} catch (err) { } catch (err) {
return void cb("INVALID_SEEDS"); return void cb({ error: "INVALID_SEEDS" });
} }
Crypt.get({ // secrets Crypt.get({ // secrets
channel: previewKeys.channel, channel: previewKeys.channel,
@ -1458,12 +1458,12 @@ define([
cryptKey: previewKeys.cryptKey, cryptKey: previewKeys.cryptKey,
}, },
}, function (err, val) { }, function (err, val) {
if (err) { return void cb(err); } if (err) { return void cb({error: err}); }
if (!val) { return void cb('DELETED'); } if (!val) { return void cb({error: 'DELETED'}); }
var json = Util.tryParse(val); var json = Util.tryParse(val);
if (!json) { return void cb("parseError"); } if (!json) { return void cb({error: "parseError"}); }
cb(void 0, json); cb(json);
}, { // cryptget opts }, { // cryptget opts
network: ctx.store.network, network: ctx.store.network,
initialState: '{}', initialState: '{}',

@ -1079,11 +1079,15 @@ define([
var bytes64; var bytes64;
var spinnerText;
var $spinner;
var inviteContent;
nThen(function (waitFor) { nThen(function (waitFor) {
$inviteDiv.append(h('div', [ $inviteDiv.append(h('div', [
h('i.fa.fa-spin.fa-spinner'), h('i.fa.fa-spin.fa-spinner'),
h('span', 'Scrypt...') // XXX spinnerText = h('span', 'Scrypt...') // XXX
])); ]));
$spinner = $(spinnerText);
setTimeout(waitFor(), 150); setTimeout(waitFor(), 150);
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
var salt = InviteInner.deriveSalt(pw, AppConfig.loginSalt); var salt = InviteInner.deriveSalt(pw, AppConfig.loginSalt);
@ -1091,26 +1095,35 @@ define([
bytes64 = bytes; bytes64 = bytes;
})); }));
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
$spinner.text('get team data'); // XXX
APP.module.execCommand('GET_INVITE_CONTENT', { APP.module.execCommand('GET_INVITE_CONTENT', {
bytes64: bytes64, bytes64: bytes64,
hash: hash, hash: hash,
password: pw, password: pw,
}, waitFor(function () { }, waitFor(function (obj) {
$div.empty(); if (obj && obj.error) {
// Wrong password or other error...
// XXX if DELETED, password prompt again?
console.error(obj.error);
waitFor.abort();
return;
}
inviteContent = obj;
// TODO // TODO
// Accept/decline/decide later UI // Accept/decline/decide later UI
})); }));
}).nThen(function (waitFor) {
}); });
}; };
nThen(function (waitFor) { nThen(function (waitFor) {
APP.module.execCommand("GET_PREVIEW_CONTENT", { APP.module.execCommand("GET_PREVIEW_CONTENT", {
seeds: seeds, seeds: seeds,
}, waitFor(function (err, json) { }, waitFor(function (json) {
if (err) { // XXX this is failing with "team is disabled" if (json && jsoN.error) { // XXX this is failing with "team is disabled"
// XXX APP.module is not ready yet? // XXX APP.module is not ready yet?
// err === DELETED: different message? // err === DELETED: different message?
$(errorBlock).text('ERROR'+err).show(); // XXX $(errorBlock).text('ERROR'+json.error).show(); // XXX
waitFor.abort(); waitFor.abort();
$div.empty(); $div.empty();
return; return;

Loading…
Cancel
Save