Merge branch 'history' into historyOO

pull/1/head
yflory 4 years ago
commit 9cbe8e3715

@ -128,7 +128,6 @@ define([
}; };
var mkHelpMenu = function (framework) { var mkHelpMenu = function (framework) {
var $codeMirrorContainer = $('#cp-app-code-container'); var $codeMirrorContainer = $('#cp-app-code-container');
$codeMirrorContainer.prepend(framework._.sfCommon.getBurnAfterReadingWarning());
var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'code']); var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'code']);
$codeMirrorContainer.prepend(helpMenu.menu); $codeMirrorContainer.prepend(helpMenu.menu);

@ -1464,7 +1464,15 @@ define([
}; };
var getVersionHash = function (clientId, data) { var getVersionHash = function (clientId, data) {
var validateKey;
var fakeNetflux = Hash.createChannelId(); var fakeNetflux = Hash.createChannelId();
nThen(function (waitFor) {
Store.getPadMetadata(null, {
channel: data.channel
}, waitFor(function (md) {
validateKey = md.validateKey;
}));
}).nThen(function () {
Store.getHistoryRange(clientId, { Store.getHistoryRange(clientId, {
cpCount: 1, cpCount: 1,
channel: data.channel, channel: data.channel,
@ -1482,11 +1490,16 @@ define([
(obj.messages || []).forEach(function (data) { (obj.messages || []).forEach(function (data) {
postMessage(clientId, "PAD_MESSAGE", { postMessage(clientId, "PAD_MESSAGE", {
msg: data.msg, msg: data.msg,
time: data.time,
user: fakeNetflux.slice(0,16), // fake history keeper to avoid validate user: fakeNetflux.slice(0,16), // fake history keeper to avoid validate
}); });
}); });
if (validateKey && store.messenger) {
store.messenger.storeValidateKey(data.channel, validateKey);
}
postMessage(clientId, "PAD_READY"); postMessage(clientId, "PAD_READY");
}); });
});
}; };
Store.joinPad = function (clientId, data) { Store.joinPad = function (clientId, data) {

@ -438,6 +438,36 @@ define([
window.dispatchEvent(evt); window.dispatchEvent(evt);
}; };
var versionHashEl;
var onInit = function () {
UI.updateLoadingProgress({
state: 2,
progress: 0.1
}, false);
stateChange(STATE.INITIALIZING);
if ($('.cp-help-container').length) {
var privateDat = cpNfInner.metadataMgr.getPrivateData();
// Burn after reading warning
$('.cp-help-container').before(common.getBurnAfterReadingWarning());
// Versioned link warning
if (privateDat.isHistoryVersion) {
versionHashEl = h('div.alert.alert-warning.cp-burn-after-reading');
$('.cp-help-container').before(versionHashEl);
}
}
common.getSframeChannel().on('EV_VERSION_TIME', function (time) {
if (!versionHashEl) { return; }
Messages.infobar_versionHash = "You're currently viewing an old version of this document ({0})."; // XXX
var vTime = time;
var vTimeStr = vTime ? new Date(vTime).toLocaleString()
: 'v' + privateDat.isHistoryVersion;
var vTxt = Messages._getKey('infobar_versionHash',  [vTimeStr]);
versionHashEl.innerText = vTxt;
versionHashEl = undefined;
});
};
var onReady = function () { var onReady = function () {
var newContentStr = cpNfInner.chainpad.getUserDoc(); var newContentStr = cpNfInner.chainpad.getUserDoc();
if (state === STATE.DELETED) { return; } if (state === STATE.DELETED) { return; }
@ -455,6 +485,7 @@ define([
var privateDat = cpNfInner.metadataMgr.getPrivateData(); var privateDat = cpNfInner.metadataMgr.getPrivateData();
var type = privateDat.app; var type = privateDat.app;
// contentUpdate may be async so we need an nthen here // contentUpdate may be async so we need an nthen here
nThen(function (waitFor) { nThen(function (waitFor) {
if (!newPad) { if (!newPad) {
@ -706,13 +737,7 @@ define([
}, },
onRemote: onRemote, onRemote: onRemote,
onLocal: onLocal, onLocal: onLocal,
onInit: function () { onInit: onInit,
UI.updateLoadingProgress({
state: 2,
progress: 0.1
}, false);
stateChange(STATE.INITIALIZING);
},
onReady: function () { evStart.reg(onReady); }, onReady: function () { evStart.reg(onReady); },
onConnectionChange: onConnectionChange, onConnectionChange: onConnectionChange,
onError: onError, onError: onError,

@ -31,12 +31,16 @@ define([], function () {
var versionHash = conf.versionHash; var versionHash = conf.versionHash;
var validateKey = metadata.validateKey; var validateKey = metadata.validateKey;
var onConnect = conf.onConnect || function () { }; var onConnect = conf.onConnect || function () { };
var lastTime; // Time of last patch (if versioned link);
conf = undefined; conf = undefined;
if (versionHash) { readOnly = true; } if (versionHash) { readOnly = true; }
padRpc.onReadyEvent.reg(function () { padRpc.onReadyEvent.reg(function () {
sframeChan.event('EV_RT_READY', null); sframeChan.event('EV_RT_READY', null);
if (lastTime && versionHash) {
sframeChan.event('EV_VERSION_TIME', lastTime);
}
}); });
// shim between chainpad and netflux // shim between chainpad and netflux
@ -86,6 +90,7 @@ define([], function () {
} }
var message = msgIn(msgObj.user, msgObj.msg); var message = msgIn(msgObj.user, msgObj.msg);
if (!message) { return; } if (!message) { return; }
lastTime = msgObj.time;
verbose(message); verbose(message);

@ -1350,11 +1350,13 @@ MessengerUI, Messages) {
} }
}; };
Messages.snaphot_title = "Snapshot"; //XXX
toolbar.setSnapshot = function (bool) { toolbar.setSnapshot = function (bool) {
toolbar.history = bool; toolbar.history = bool;
toolbar.title.toggleClass('cp-toolbar-unsync', bool); toolbar.title.toggleClass('cp-toolbar-unsync', bool);
if (bool && toolbar.spinner) { if (bool && toolbar.spinner) {
toolbar.spinner.text("SNAPSHOT"); // XXX toolbar.spinner.text(Messages.snaphot_title);
} else { } else {
kickSpinner(toolbar, config); kickSpinner(toolbar, config);
} }
@ -1363,7 +1365,7 @@ MessengerUI, Messages) {
toolbar.history = bool; toolbar.history = bool;
toolbar.title.toggleClass('cp-toolbar-unsync', bool); toolbar.title.toggleClass('cp-toolbar-unsync', bool);
if (bool && toolbar.spinner) { if (bool && toolbar.spinner) {
toolbar.spinner.text("HISTORY"); // XXX toolbar.spinner.text(Messages.historyText);
} else { } else {
kickSpinner(toolbar, config); kickSpinner(toolbar, config);
} }

@ -1013,7 +1013,6 @@ define([
var mkHelpMenu = function (framework) { var mkHelpMenu = function (framework) {
var $toolbarContainer = $('#cp-app-kanban-container'); var $toolbarContainer = $('#cp-app-kanban-container');
$toolbarContainer.prepend(framework._.sfCommon.getBurnAfterReadingWarning());
var helpMenu = framework._.sfCommon.createHelpMenu(['kanban']); var helpMenu = framework._.sfCommon.createHelpMenu(['kanban']);
$toolbarContainer.prepend(helpMenu.menu); $toolbarContainer.prepend(helpMenu.menu);

@ -206,7 +206,6 @@ define([
var mkHelpMenu = function(framework) { var mkHelpMenu = function(framework) {
var $toolbarContainer = $('.cke_toolbox_main'); var $toolbarContainer = $('.cke_toolbox_main');
$toolbarContainer.before(framework._.sfCommon.getBurnAfterReadingWarning());
var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'pad']); var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'pad']);
$toolbarContainer.before(helpMenu.menu); $toolbarContainer.before(helpMenu.menu);

@ -428,7 +428,6 @@ define([
var mkHelpMenu = function (framework) { var mkHelpMenu = function (framework) {
var $codeMirrorContainer = $('#cp-app-slide-editor-container'); var $codeMirrorContainer = $('#cp-app-slide-editor-container');
$codeMirrorContainer.prepend(framework._.sfCommon.getBurnAfterReadingWarning());
var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'slide']); var helpMenu = framework._.sfCommon.createHelpMenu(['text', 'slide']);
$codeMirrorContainer.prepend(helpMenu.menu); $codeMirrorContainer.prepend(helpMenu.menu);

@ -250,7 +250,6 @@ define([
var mkHelpMenu = function (framework) { var mkHelpMenu = function (framework) {
var $appContainer = $('#cp-app-whiteboard-container'); var $appContainer = $('#cp-app-whiteboard-container');
$appContainer.prepend(framework._.sfCommon.getBurnAfterReadingWarning());
var helpMenu = framework._.sfCommon.createHelpMenu(['whiteboard']); var helpMenu = framework._.sfCommon.createHelpMenu(['whiteboard']);
$appContainer.prepend(helpMenu.menu); $appContainer.prepend(helpMenu.menu);
framework._.toolbar.$drawer.append(helpMenu.button); framework._.toolbar.$drawer.append(helpMenu.button);

Loading…
Cancel
Save