Add history to pad2

This commit is contained in:
yflory
2017-08-21 17:40:21 +02:00
parent b2e6df1f9d
commit 8d837d22ea
5 changed files with 84 additions and 12 deletions

View File

@@ -5,15 +5,18 @@ define([
'/common/sframe-channel.js',
'/common/sframe-common-title.js',
'/common/sframe-common-interface.js',
'/common/sframe-common-history.js',
'/common/metadata-manager.js',
'/common/cryptpad-common.js'
], function (nThen, Messages, CpNfInner, SFrameChannel, Title, UI, MetadataMgr, Cryptpad) {
], function (nThen, Messages, CpNfInner, SFrameChannel, Title, UI, History, MetadataMgr, Cryptpad) {
// Chainpad Netflux Inner
var funcs = {};
var ctx = {};
funcs.Messages = Messages;
funcs.startRealtime = function (options) {
if (ctx.cpNfInner) { return ctx.cpNfInner; }
options.sframeChan = ctx.sframeChan;
@@ -23,6 +26,13 @@ define([
return ctx.cpNfInner;
};
funcs.getMetadataMgr = function () {
return ctx.metadataMgr;
};
funcs.getCryptpadCommon = function () {
return Cryptpad;
};
var isLoggedIn = funcs.isLoggedIn = function () {
if (!ctx.cpNfInner) { throw new Error("cpNfInner is not ready!"); }
return ctx.cpNfInner.metadataMgr.getPrivateData().accountName;
@@ -38,6 +48,9 @@ define([
funcs.createUserAdminMenu = UI.createUserAdminMenu;
funcs.displayAvatar = UI.displayAvatar;
// History
funcs.getHistory = function (config) { return History.create(funcs, config); };
// Title module
funcs.createTitle = Title.create;
@@ -79,6 +92,13 @@ define([
});
};
funcs.getFullHistory = function (realtime, cb) {
ctx.sframeChan.on('EV_RT_HIST_MESSAGE', function (content) {
realtime.message(content);
});
ctx.sframeChan.query('Q_GET_FULL_HISTORY', null, cb);
};
// TODO
funcs.feedback = function () {};
@@ -199,10 +219,10 @@ define([
}
break;
case 'history':
if (!AppConfig.enableHistory) {
/*if (!AppConfig.enableHistory) {
button = $('<span>');
break;
}
}*/
button = $('<button>', {
title: Messages.historyButton,
'class': "fa fa-history history",
@@ -211,7 +231,7 @@ define([
button
.click(prepareFeedback(type))
.on('click', function () {
common.getHistory(data.histConfig);
funcs.getHistory(data.histConfig);
});
}
break;