Preserve chat and cursor channel when importing a template
This commit is contained in:
parent
1a0344547b
commit
f883fb7e04
@ -1916,7 +1916,13 @@ define([
|
||||
onSelect: function (data) {
|
||||
if (data.type === type && first) {
|
||||
UI.addLoadingScreen({hideTips: true});
|
||||
sframeChan.query('Q_TEMPLATE_USE', data.href, function () {
|
||||
var chatChan = common.getPadChat();
|
||||
var cursorChan = common.getCursorChannel();
|
||||
sframeChan.query('Q_TEMPLATE_USE', {
|
||||
href: data.href,
|
||||
chat: chatChan,
|
||||
cursor: cursorChan
|
||||
}, function () {
|
||||
first = false;
|
||||
UI.removeLoadingScreen();
|
||||
Feedback.send('TEMPLATE_USED');
|
||||
|
||||
@ -493,9 +493,10 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
common.useTemplate = function (href, Crypt, cb, optsPut) {
|
||||
common.useTemplate = function (data, Crypt, cb, optsPut) {
|
||||
// opts is used to overrides options for chainpad-netflux in cryptput
|
||||
// it allows us to add owners and expiration time if it is a new file
|
||||
var href = data.href;
|
||||
|
||||
var parsed = Hash.parsePadUrl(href);
|
||||
var parsed2 = Hash.parsePadUrl(window.location.href);
|
||||
@ -531,8 +532,13 @@ define([
|
||||
}
|
||||
if (typeof(meta) === "object") {
|
||||
meta.defaultTitle = meta.title || meta.defaultTitle;
|
||||
delete meta.users;
|
||||
meta.title = "";
|
||||
delete meta.users;
|
||||
delete meta.chat2;
|
||||
delete meta.chat;
|
||||
delete meta.cursor;
|
||||
if (data.chat) { meta.chat2 = data.chat; }
|
||||
if (data.cursor) { meta.cursor = data.cursor; }
|
||||
}
|
||||
val = JSON.stringify(parsed);
|
||||
} catch (e) {
|
||||
|
||||
@ -647,8 +647,8 @@ define([
|
||||
initFilePicker(data);
|
||||
});
|
||||
|
||||
sframeChan.on('Q_TEMPLATE_USE', function (href, cb) {
|
||||
Cryptpad.useTemplate(href, Cryptget, cb);
|
||||
sframeChan.on('Q_TEMPLATE_USE', function (data, cb) {
|
||||
Cryptpad.useTemplate(data, Cryptget, cb);
|
||||
});
|
||||
sframeChan.on('Q_TEMPLATE_EXIST', function (type, cb) {
|
||||
Cryptpad.listTemplates(type, function (err, templates) {
|
||||
@ -953,7 +953,9 @@ define([
|
||||
// we need to have the owners and expiration time in the first line on the
|
||||
// server
|
||||
var cryptputCfg = $.extend(true, {}, rtConfig, {password: password});
|
||||
Cryptpad.useTemplate(data.template, Cryptget, function () {
|
||||
Cryptpad.useTemplate({
|
||||
href: data.template
|
||||
}, Cryptget, function () {
|
||||
startRealtime();
|
||||
cb();
|
||||
}, cryptputCfg);
|
||||
|
||||
@ -168,12 +168,15 @@ define([
|
||||
|
||||
// Chat
|
||||
var padChatChannel;
|
||||
// common-ui-elements needs to be able to get the chat channel to put it in metadata when
|
||||
// importing a template
|
||||
funcs.getPadChat = function () {
|
||||
return padChatChannel;
|
||||
};
|
||||
funcs.openPadChat = function (saveChanges) {
|
||||
var md = JSON.parse(JSON.stringify(ctx.metadataMgr.getMetadata()));
|
||||
//if (md.chat) { delete md.chat; } // Old channel without signing key
|
||||
// NOTE: "chat2" is also used in cryptpad-common's "useTemplate"
|
||||
var channel = md.chat2 || Hash.createChannelId();
|
||||
if (!md.chat2) {
|
||||
md.chat2 = channel;
|
||||
@ -187,6 +190,8 @@ define([
|
||||
};
|
||||
|
||||
var cursorChannel;
|
||||
// common-ui-elements needs to be able to get the cursor channel to put it in metadata when
|
||||
// importing a template
|
||||
funcs.getCursorChannel = function () {
|
||||
return cursorChannel;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user