Don't show saved in OO until the ACK is received

pull/1/head
yflory 4 years ago
parent c29219c969
commit e405dcff7e

@ -99,6 +99,9 @@ define([
var sessionId = Hash.createChannelId(); var sessionId = Hash.createChannelId();
var cpNfInner; var cpNfInner;
var evOnPatch = Util.mkEvent();
var evOnSync = Util.mkEvent();
// This structure is used for caching media data and blob urls for each media cryptpad url // This structure is used for caching media data and blob urls for each media cryptpad url
var mediasData = {}; var mediasData = {};
@ -261,13 +264,17 @@ define([
}); });
}, },
sendMsg: function (msg, cp, cb) { sendMsg: function (msg, cp, cb) {
evOnPatch.fire();
rtChannel.sendCmd({ rtChannel.sendCmd({
cmd: 'SEND_MESSAGE', cmd: 'SEND_MESSAGE',
data: { data: {
msg: msg, msg: msg,
isCp: cp isCp: cp
} }
}, cb); }, function (err, h) {
if (!err) { evOnSync.fire(); }
cb(err, h);
});
}, },
}; };
@ -1221,6 +1228,7 @@ define([
} }
}, },
"onDocumentReady": function () { "onDocumentReady": function () {
evOnSync.fire();
var onMigrateRdy = Util.mkEvent(); var onMigrateRdy = Util.mkEvent();
onMigrateRdy.reg(function () { onMigrateRdy.reg(function () {
var div = h('div.cp-oo-x2tXls', [ var div = h('div.cp-oo-x2tXls', [
@ -1963,6 +1971,10 @@ define([
metadataMgr: metadataMgr, metadataMgr: metadataMgr,
readOnly: readOnly, readOnly: readOnly,
realtime: info.realtime, realtime: info.realtime,
spinner: {
onPatch: evOnPatch,
onSync: evOnSync
},
sfCommon: common, sfCommon: common,
$container: $bar, $container: $bar,
$contentContainer: $('#cp-app-oo-container') $contentContainer: $('#cp-app-oo-container')

@ -879,6 +879,14 @@ MessengerUI, Messages) {
$spin.text(Messages.saved); $spin.text(Messages.saved);
}, /*local ? 0 :*/ SPINNER_DISAPPEAR_TIME); }, /*local ? 0 :*/ SPINNER_DISAPPEAR_TIME);
}; };
if (config.spinner) {
var h = function () {
onSynced();
try { config.spinner.onSync.unreg(h); } catch (e) { console.error(e); }
};
config.spinner.onSync.reg(h);
return;
}
config.sfCommon.whenRealtimeSyncs(onSynced); config.sfCommon.whenRealtimeSyncs(onSynced);
}; };
var ks = function (toolbar, config, local) { var ks = function (toolbar, config, local) {
@ -891,6 +899,15 @@ MessengerUI, Messages) {
var $spin = $('<span>', {'class': SPINNER_CLS}).appendTo(toolbar.title); var $spin = $('<span>', {'class': SPINNER_CLS}).appendTo(toolbar.title);
$spin.text(Messages.synchronizing); $spin.text(Messages.synchronizing);
if (config.spinner) {
config.spinner.onPatch.reg(ks(toolbar, config));
typing = 0;
setTimeout(function () {
kickSpinner(toolbar, config);
});
return $spin;
}
if (config.realtime) { if (config.realtime) {
config.realtime.onPatch(ks(toolbar, config)); config.realtime.onPatch(ks(toolbar, config));
config.realtime.onMessage(ks(toolbar, config, true)); config.realtime.onMessage(ks(toolbar, config, true));

Loading…
Cancel
Save