Fix race condition at registration

pull/1/head
yflory 7 years ago
parent b5bb83b700
commit f18917f0ac

@ -80,7 +80,7 @@ define([
var rt = opt.rt = Listmap.create(config); var rt = opt.rt = Listmap.create(config);
rt.proxy rt.proxy
.on('ready', function () { .on('ready', function () {
cb(void 0, rt); setTimeout(function () { cb(void 0, rt); });
}) })
.on('disconnect', function (info) { .on('disconnect', function (info) {
cb('E_DISCONNECT', info); cb('E_DISCONNECT', info);
@ -162,9 +162,16 @@ define([
sessionStorage.migrateAnonDrive = 1; sessionStorage.migrateAnonDrive = 1;
} }
Realtime.whenRealtimeSyncs(rt.realtime, function () { // We have to call whenRealtimeSyncs asynchronously here because in the current
LocalStore.login(res.userHash, res.userName, function () { // version of listmap, onLocal calls `chainpad.contentUpdate(newValue)`
cb(void 0, res); // asynchronously.
// The following setTimeout is here to make sure whenRealtimeSyncs is called after
// `contentUpdate` so that we have an update userDoc in chainpad.
setTimeout(function () {
Realtime.whenRealtimeSyncs(rt.realtime, function () {
LocalStore.login(res.userHash, res.userName, function () {
setTimeout(function () { cb(void 0, res); });
});
}); });
}); });
}); });

Loading…
Cancel
Save