add api to check whether the realtime has synced with the server

pull/1/head
ansuz 8 years ago
parent 3b1bd2f720
commit f723585758

@ -44,6 +44,18 @@ define([
return;
};
var whenRealtimeSyncs = common.whenRealtimeSyncs = function (realtime, cb) {
realtime.sync();
var interval = 300;
var check = function () {
if (realtime.getAuthDoc() !== realtime.getUserDoc()) {
return window.setTimeout(check, interval);
}
cb();
};
window.setTimeout(check, interval);
};
var getWebsocketURL = common.getWebsocketURL = function () {
if (!Config.websocketPath) { return Config.websocketURL; }
var path = Config.websocketPath;

@ -51,7 +51,7 @@ define([
}
[ $uname, $passwd, $confirm]
.some(function ($el) { if (!$el.val()) { return ($el.focus(), true); } });
.some(function ($el) { if (!$el.val()) { $el.focus(); return true; } });
// checkboxes
var $checkImport = $('#import-recent');
@ -60,18 +60,6 @@ define([
var $register = $('button#register');
var proxyIsSynced = function (realtime, cb) {
realtime.sync();
var interval = 300;
var check = function () {
if (realtime.getAuthDoc() !== realtime.getUserDoc()) {
return window.setTimeout(check, interval);
}
cb();
};
window.setTimeout(check, interval);
};
$register.click(function () {
var uname = $uname.val();
var passwd = $passwd.val();
@ -108,7 +96,7 @@ define([
proxy.login_name = uname;
proxyIsSynced(result.realtime, function () {
Cryptpad.whenRealtimeSyncs(result.realtime, function () {
document.location.href = '/drive/';
});
});

Loading…
Cancel
Save