add api to check whether the realtime has synced with the server
This commit is contained in:
@@ -44,6 +44,18 @@ define([
|
|||||||
return;
|
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 () {
|
var getWebsocketURL = common.getWebsocketURL = function () {
|
||||||
if (!Config.websocketPath) { return Config.websocketURL; }
|
if (!Config.websocketPath) { return Config.websocketURL; }
|
||||||
var path = Config.websocketPath;
|
var path = Config.websocketPath;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ $uname, $passwd, $confirm]
|
[ $uname, $passwd, $confirm]
|
||||||
.some(function ($el) { if (!$el.val()) { return ($el.focus(), true); } });
|
.some(function ($el) { if (!$el.val()) { $el.focus(); return true; } });
|
||||||
|
|
||||||
// checkboxes
|
// checkboxes
|
||||||
var $checkImport = $('#import-recent');
|
var $checkImport = $('#import-recent');
|
||||||
@@ -60,18 +60,6 @@ define([
|
|||||||
|
|
||||||
var $register = $('button#register');
|
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 () {
|
$register.click(function () {
|
||||||
var uname = $uname.val();
|
var uname = $uname.val();
|
||||||
var passwd = $passwd.val();
|
var passwd = $passwd.val();
|
||||||
@@ -108,7 +96,7 @@ define([
|
|||||||
|
|
||||||
proxy.login_name = uname;
|
proxy.login_name = uname;
|
||||||
|
|
||||||
proxyIsSynced(result.realtime, function () {
|
Cryptpad.whenRealtimeSyncs(result.realtime, function () {
|
||||||
document.location.href = '/drive/';
|
document.location.href = '/drive/';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user