cryptpad/www/common/common-realtime.js

22 lines
579 B
JavaScript
Raw Normal View History

2017-11-30 15:01:17 +01:00
define([], function () {
2017-08-11 10:59:54 +02:00
var common = {};
/*
TODO make this not blow up when disconnected or lagging...
*/
common.whenRealtimeSyncs = function (realtime, cb) {
if (typeof(realtime.getAuthDoc) !== 'function') {
return void console.error('improper use of this function');
}
2017-11-30 15:01:17 +01:00
setTimeout(function () {
2017-08-11 10:59:54 +02:00
if (realtime.getAuthDoc() === realtime.getUserDoc()) {
return void cb();
} else {
realtime.onSettle(cb);
2017-08-11 10:59:54 +02:00
}
}, 0);
};
return common;
});