Merge branch 'staging' into debugtime

This commit is contained in:
yflory
2020-04-03 11:20:03 +02:00
31 changed files with 1117 additions and 60345 deletions

View File

@@ -1499,6 +1499,13 @@ define([
return;
}
var onError = function (err) {
channel.bcast("PAD_ERROR", err);
// If this is a DELETED, EXPIRED or RESTRICTED pad, leave the channel
if (["EDELETED", "EEXPIRED", "ERESTRICTED"].indexOf(err.type) === -1) { return; }
Store.leavePad(null, data, function () {});
};
var conf = {
onReady: function (pad) {
var padData = pad.metadata || {};
@@ -1522,14 +1529,8 @@ define([
onLeave: function (m) {
channel.bcast("PAD_LEAVE", m);
},
onError: function (err) {
channel.bcast("PAD_ERROR", err);
Store.leavePad(null, data, function () {});
},
onChannelError: function (err) {
channel.bcast("PAD_ERROR", err);
Store.leavePad(null, data, function () {});
},
onError: onError,
onChannelError: onError,
onRejected: function (allowed, _cb) {
var cb = Util.once(Util.mkAsync(_cb));
@@ -1595,7 +1596,10 @@ define([
onConnect: function (wc, sendMessage) {
channel.sendMessage = function (msg, cId, cb) {
// Send to server
sendMessage(msg, function () {
sendMessage(msg, function (err) {
if (err) {
return void cb({ error: err });
}
// Broadcast to other tabs
channel.pushHistory(CpNetflux.removeCp(msg), /^cp\|/.test(msg));
channel.bcast("PAD_MESSAGE", {

View File

@@ -45,10 +45,13 @@ define([
var txid = mkTxid();
opts = opts || {};
var to = opts.timeout || 30000;
var timeout = setTimeout(function () {
delete queries[txid];
cb('TIMEOUT');
}, to);
var timeout;
if (to > 0) {
timeout = setTimeout(function () {
delete queries[txid];
cb('TIMEOUT');
}, to);
}
acks[txid] = function (err) {
clearTimeout(timeout);
delete acks[txid];