cryptpad/www/common/common-realtime.js

26 lines
721 B
JavaScript
Raw Permalink Normal View History

2023-10-20 22:35:26 +08:00
// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
//
// SPDX-License-Identifier: AGPL-3.0-or-later
2017-11-30 22:01:17 +08:00
define([], function () {
2017-08-11 16:59:54 +08: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 22:01:17 +08:00
setTimeout(function () {
2017-08-11 16:59:54 +08:00
if (realtime.getAuthDoc() === realtime.getUserDoc()) {
return void cb();
} else {
realtime.onSettle(cb);
2017-08-11 16:59:54 +08:00
}
}, 0);
};
return common;
});