Fix broken browser fight logging

This commit is contained in:
Caleb James DeLisle
2017-10-09 14:12:55 +03:00
parent f0eb58ee95
commit 828a685ba8

View File

@@ -162,27 +162,26 @@ define([
/* pushing back over the wire is necessary, but it can /* pushing back over the wire is necessary, but it can
result in a feedback loop, which we call a browser result in a feedback loop, which we call a browser
fight */ fight */
if (module.logFights) {
// what changed? // what changed?
var op = TextPatcher.diff(newContentStrNoMeta, newContent2StrNoMeta); var op = TextPatcher.diff(newContentStrNoMeta, newContent2StrNoMeta);
// log the changes // log the changes
TextPatcher.log(newContentStrNoMeta, op); TextPatcher.log(newContentStrNoMeta, op);
var sop = JSON.stringify(TextPatcher.format(newContentStrNoMeta, op)); var sop = JSON.stringify(TextPatcher.format(newContentStrNoMeta, op));
var index = module.fights.indexOf(sop); var fights = window.CryptPad_fights = window.CryptPad_fights || [];
var index = fights.indexOf(sop);
if (index === -1) { if (index === -1) {
module.fights.push(sop); fights.push(sop);
console.log("Found a new type of browser disagreement"); console.log("Found a new type of browser disagreement");
console.log("You can inspect the list in your " + console.log("You can inspect the list in your " +
"console at `REALTIME_MODULE.fights`"); "console at `REALTIME_MODULE.fights`");
console.log(module.fights); console.log(fights);
} else { } else {
console.log("Encountered a known browser disagreement: " + console.log("Encountered a known browser disagreement: " +
"available at `REALTIME_MODULE.fights[%s]`", index); "available at `REALTIME_MODULE.fights[%s]`", index);
} }
} }
} }
}
// Notify only when the content has changed, not when someone has joined/left // Notify only when the content has changed, not when someone has joined/left
if (JSONSortify(newContent) !== JSONSortify(oldContent)) { if (JSONSortify(newContent) !== JSONSortify(oldContent)) {