handle RPC_NOT_READY error for logged out users
This commit is contained in:
parent
a9f8f42e3c
commit
9b8866ed72
@ -717,14 +717,14 @@ define([
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!rpc) {
|
if (!rpc) {
|
||||||
console.error('[RPC_NOT_READY]');
|
console.error('RPC_NOT_READY');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
common.arePinsSynced = function (cb) {
|
common.arePinsSynced = function (cb) {
|
||||||
if (!pinsReady()) { return void cb ('[RPC_NOT_READY]'); }
|
if (!pinsReady()) { return void cb ('RPC_NOT_READY'); }
|
||||||
|
|
||||||
var list = getCanonicalChannelList();
|
var list = getCanonicalChannelList();
|
||||||
var local = Hash.hashChannelList(list);
|
var local = Hash.hashChannelList(list);
|
||||||
@ -735,7 +735,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
common.resetPins = function (cb) {
|
common.resetPins = function (cb) {
|
||||||
if (!pinsReady()) { return void cb ('[RPC_NOT_READY]'); }
|
if (!pinsReady()) { return void cb ('RPC_NOT_READY'); }
|
||||||
|
|
||||||
var list = getCanonicalChannelList();
|
var list = getCanonicalChannelList();
|
||||||
rpc.reset(list, function (e, hash) {
|
rpc.reset(list, function (e, hash) {
|
||||||
@ -745,7 +745,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
common.pinPads = function (pads, cb) {
|
common.pinPads = function (pads, cb) {
|
||||||
if (!pinsReady()) { return void cb ('[RPC_NOT_READY]'); }
|
if (!pinsReady()) { return void cb ('RPC_NOT_READY'); }
|
||||||
|
|
||||||
rpc.pin(pads, function (e, hash) {
|
rpc.pin(pads, function (e, hash) {
|
||||||
if (e) { return void cb(e); }
|
if (e) { return void cb(e); }
|
||||||
@ -754,7 +754,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
common.unpinPads = function (pads, cb) {
|
common.unpinPads = function (pads, cb) {
|
||||||
if (!pinsReady()) { return void cb ('[RPC_NOT_READY]'); }
|
if (!pinsReady()) { return void cb ('RPC_NOT_READY'); }
|
||||||
|
|
||||||
rpc.unpin(pads, function (e, hash) {
|
rpc.unpin(pads, function (e, hash) {
|
||||||
if (e) { return void cb(e); }
|
if (e) { return void cb(e); }
|
||||||
@ -763,7 +763,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
common.getPinnedUsage = function (cb) {
|
common.getPinnedUsage = function (cb) {
|
||||||
if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); }
|
if (!pinsReady()) { return void cb('RPC_NOT_READY'); }
|
||||||
|
|
||||||
rpc.getFileListSize(function (err, bytes) {
|
rpc.getFileListSize(function (err, bytes) {
|
||||||
if (typeof(bytes) === 'number') {
|
if (typeof(bytes) === 'number') {
|
||||||
@ -774,6 +774,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
common.getFileSize = function (href, cb) {
|
common.getFileSize = function (href, cb) {
|
||||||
|
if (!pinsReady()) { return void cb('RPC_NOT_READY'); }
|
||||||
var channelId = Hash.hrefToHexChannelId(href);
|
var channelId = Hash.hrefToHexChannelId(href);
|
||||||
rpc.getFileSize(channelId, function (e, bytes) {
|
rpc.getFileSize(channelId, function (e, bytes) {
|
||||||
if (e) { return void cb(e); }
|
if (e) { return void cb(e); }
|
||||||
@ -782,7 +783,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
common.updatePinLimit = function (cb) {
|
common.updatePinLimit = function (cb) {
|
||||||
if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); }
|
if (!pinsReady()) { return void cb('RPC_NOT_READY'); }
|
||||||
rpc.updatePinLimits(function (e, limit, plan, note) {
|
rpc.updatePinLimits(function (e, limit, plan, note) {
|
||||||
if (e) { return cb(e); }
|
if (e) { return cb(e); }
|
||||||
common.account.limit = limit;
|
common.account.limit = limit;
|
||||||
@ -793,7 +794,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
common.getPinLimit = function (cb) {
|
common.getPinLimit = function (cb) {
|
||||||
if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); }
|
if (!pinsReady()) { return void cb('RPC_NOT_READY'); }
|
||||||
|
|
||||||
var account = common.account;
|
var account = common.account;
|
||||||
if (typeof(account.limit) !== 'number' ||
|
if (typeof(account.limit) !== 'number' ||
|
||||||
@ -831,17 +832,17 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
common.uploadComplete = function (cb) {
|
common.uploadComplete = function (cb) {
|
||||||
if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); }
|
if (!pinsReady()) { return void cb('RPC_NOT_READY'); }
|
||||||
rpc.uploadComplete(cb);
|
rpc.uploadComplete(cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
common.uploadStatus = function (size, cb) {
|
common.uploadStatus = function (size, cb) {
|
||||||
if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); }
|
if (!pinsReady()) { return void cb('RPC_NOT_READY'); }
|
||||||
rpc.uploadStatus(size, cb);
|
rpc.uploadStatus(size, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
common.uploadCancel = function (cb) {
|
common.uploadCancel = function (cb) {
|
||||||
if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); }
|
if (!pinsReady()) { return void cb('RPC_NOT_READY'); }
|
||||||
rpc.uploadCancel(cb);
|
rpc.uploadCancel(cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -164,19 +164,28 @@ define([
|
|||||||
Cryptpad.removeLoadingScreen();
|
Cryptpad.removeLoadingScreen();
|
||||||
$dllabel.append($('<br>'));
|
$dllabel.append($('<br>'));
|
||||||
$dllabel.append(Cryptpad.fixHTML(metadata.name));
|
$dllabel.append(Cryptpad.fixHTML(metadata.name));
|
||||||
$dllabel.append($('<br>'));
|
|
||||||
$dllabel.append(Messages._getKey('formattedMB', [sizeMb]));
|
// don't display the size if you don't know it.
|
||||||
|
if (typeof(sizeM) === 'number') {
|
||||||
|
$dllabel.append($('<br>'));
|
||||||
|
$dllabel.append(Messages._getKey('formattedMB', [sizeMb]));
|
||||||
|
}
|
||||||
var decrypting = false;
|
var decrypting = false;
|
||||||
var onClick = function (ev) {
|
var onClick = function (ev) {
|
||||||
if (decrypting) { return; }
|
if (decrypting) { return; }
|
||||||
decrypting = true;
|
decrypting = true;
|
||||||
displayFile(ev, sizeMb);
|
displayFile(ev, sizeMb);
|
||||||
};
|
};
|
||||||
if (sizeMb < 5) { return void onClick(); }
|
if (typeof(sizeMb) === 'number' && sizeMb < 5) { return void onClick(); }
|
||||||
$dlform.find('#dl, #progress').click(onClick);
|
$dlform.find('#dl, #progress').click(onClick);
|
||||||
};
|
};
|
||||||
Cryptpad.getFileSize(window.location.href, function (e, data) {
|
Cryptpad.getFileSize(window.location.href, function (e, data) {
|
||||||
if (e) { return void Cryptpad.errorLoadingScreen(e); }
|
if (e) {
|
||||||
|
// TODO when GET_FILE_SIZE is made unauthenticated
|
||||||
|
// you won't need to handle this error (there won't be one)
|
||||||
|
if (e === 'RPC_NOT_READY') { return todoBigFile(); }
|
||||||
|
return void Cryptpad.errorLoadingScreen(e);
|
||||||
|
}
|
||||||
var size = Cryptpad.bytesToMegabytes(data);
|
var size = Cryptpad.bytesToMegabytes(data);
|
||||||
return void todoBigFile(size);
|
return void todoBigFile(size);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user