Merge branch 'history' into historyOO

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

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

@ -1464,7 +1464,15 @@ define([
};
var getVersionHash = function (clientId, data) {
var validateKey;
var fakeNetflux = Hash.createChannelId();
nThen(function (waitFor) {
Store.getPadMetadata(null, {
channel: data.channel
}, waitFor(function (md) {
validateKey = md.validateKey;
}));
}).nThen(function () {
Store.getHistoryRange(clientId, {
cpCount: 1,
channel: data.channel,
@ -1482,11 +1490,16 @@ define([
(obj.messages || []).forEach(function (data) {
postMessage(clientId, "PAD_MESSAGE", {
msg: data.msg,
time: data.time,
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");
});
});
};
Store.joinPad = function (clientId, data) {

@ -438,6 +438,36 @@ define([
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 newContentStr = cpNfInner.chainpad.getUserDoc();
if (state === STATE.DELETED) { return; }
@ -455,6 +485,7 @@ define([
var privateDat = cpNfInner.metadataMgr.getPrivateData();
var type = privateDat.app;
// contentUpdate may be async so we need an nthen here
nThen(function (waitFor) {
if (!newPad) {
@ -706,13 +737,7 @@ define([
},
onRemote: onRemote,
onLocal: onLocal,
onInit: function () {
UI.updateLoadingProgress({
state: 2,
progress: 0.1
}, false);
stateChange(STATE.INITIALIZING);
},
onInit: onInit,
onReady: function () { evStart.reg(onReady); },
onConnectionChange: onConnectionChange,
onError: onError,

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

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

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

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

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

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

Loading…
Cancel
Save