Progress bar for loading a pad (framework only)

pull/1/head
yflory 6 years ago
parent 264f7dc6a1
commit 475301477f

@ -288,7 +288,7 @@ define([
var newContentStr = cpNfInner.chainpad.getUserDoc();
if (state === STATE.DELETED) { return; }
//UI.updateLoadingProgress({ state: -1 }, false);
UI.updateLoadingProgress({ state: -1 }, false);
var newPad = false;
if (newContentStr === '') { newPad = true; }
@ -452,9 +452,9 @@ define([
nThen(function (waitFor) {
UI.addLoadingScreen();
SFCommon.create(waitFor(function (c) { common = c; }));
/*UI.updateLoadingProgress({
UI.updateLoadingProgress({
state: 1
}, false);*/
}, false);
}).nThen(function (waitFor) {
common.getSframeChannel().onReady(waitFor());
}).nThen(function (waitFor) {
@ -481,14 +481,16 @@ define([
onRemote: onRemote,
onLocal: onLocal,
onInit: function () {
/*UI.updateLoadingProgress({
state: 2
}, false);*/
UI.updateLoadingProgress({
state: 2,
progress: 0.1
}, false);
stateChange(STATE.INITIALIZING);
},
onReady: function () { evStart.reg(onReady); },
onConnectionChange: onConnectionChange,
onError: onError
onError: onError,
updateLoadingProgress: UI.updateLoadingProgress
});
var privReady = Util.once(waitFor());

@ -45,6 +45,7 @@ define([
var readOnly = config.readOnly || false;
var sframeChan = config.sframeChan;
var metadataMgr = config.metadataMgr;
var updateLoadingProgress = config.updateLoadingProgress;
config = undefined;
var chainpad = ChainPad.create({
@ -64,6 +65,7 @@ define([
var myID;
var isReady = false;
var isHistory = 1;
var evConnected = Util.mkEvent(true);
var evInfiniteSpinner = Util.mkEvent(true);
@ -114,11 +116,19 @@ define([
onLocal(true); // should be onBeforeMessage
}
chainpad.message(content);
if (isHistory && updateLoadingProgress) {
updateLoadingProgress({
state: 2,
progress: isHistory
}, false);
isHistory++;
}
cb('OK');
});
sframeChan.on('EV_RT_READY', function () {
if (isReady) { return; }
isReady = true;
isHistory = false;
chainpad.start();
setMyID({ myID: myID });
onReady({ realtime: chainpad });

Loading…
Cancel
Save