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) {
|
onSelect: function (data) {
|
||||||
if (data.type === type && first) {
|
if (data.type === type && first) {
|
||||||
UI.addLoadingScreen({hideTips: true});
|
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;
|
first = false;
|
||||||
UI.removeLoadingScreen();
|
UI.removeLoadingScreen();
|
||||||
Feedback.send('TEMPLATE_USED');
|
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
|
// 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
|
// 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 parsed = Hash.parsePadUrl(href);
|
||||||
var parsed2 = Hash.parsePadUrl(window.location.href);
|
var parsed2 = Hash.parsePadUrl(window.location.href);
|
||||||
@ -531,8 +532,13 @@ define([
|
|||||||
}
|
}
|
||||||
if (typeof(meta) === "object") {
|
if (typeof(meta) === "object") {
|
||||||
meta.defaultTitle = meta.title || meta.defaultTitle;
|
meta.defaultTitle = meta.title || meta.defaultTitle;
|
||||||
delete meta.users;
|
|
||||||
meta.title = "";
|
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);
|
val = JSON.stringify(parsed);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -647,8 +647,8 @@ define([
|
|||||||
initFilePicker(data);
|
initFilePicker(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
sframeChan.on('Q_TEMPLATE_USE', function (href, cb) {
|
sframeChan.on('Q_TEMPLATE_USE', function (data, cb) {
|
||||||
Cryptpad.useTemplate(href, Cryptget, cb);
|
Cryptpad.useTemplate(data, Cryptget, cb);
|
||||||
});
|
});
|
||||||
sframeChan.on('Q_TEMPLATE_EXIST', function (type, cb) {
|
sframeChan.on('Q_TEMPLATE_EXIST', function (type, cb) {
|
||||||
Cryptpad.listTemplates(type, function (err, templates) {
|
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
|
// we need to have the owners and expiration time in the first line on the
|
||||||
// server
|
// server
|
||||||
var cryptputCfg = $.extend(true, {}, rtConfig, {password: password});
|
var cryptputCfg = $.extend(true, {}, rtConfig, {password: password});
|
||||||
Cryptpad.useTemplate(data.template, Cryptget, function () {
|
Cryptpad.useTemplate({
|
||||||
|
href: data.template
|
||||||
|
}, Cryptget, function () {
|
||||||
startRealtime();
|
startRealtime();
|
||||||
cb();
|
cb();
|
||||||
}, cryptputCfg);
|
}, cryptputCfg);
|
||||||
|
|||||||
@ -168,12 +168,15 @@ define([
|
|||||||
|
|
||||||
// Chat
|
// Chat
|
||||||
var padChatChannel;
|
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 () {
|
funcs.getPadChat = function () {
|
||||||
return padChatChannel;
|
return padChatChannel;
|
||||||
};
|
};
|
||||||
funcs.openPadChat = function (saveChanges) {
|
funcs.openPadChat = function (saveChanges) {
|
||||||
var md = JSON.parse(JSON.stringify(ctx.metadataMgr.getMetadata()));
|
var md = JSON.parse(JSON.stringify(ctx.metadataMgr.getMetadata()));
|
||||||
//if (md.chat) { delete md.chat; } // Old channel without signing key
|
//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();
|
var channel = md.chat2 || Hash.createChannelId();
|
||||||
if (!md.chat2) {
|
if (!md.chat2) {
|
||||||
md.chat2 = channel;
|
md.chat2 = channel;
|
||||||
@ -187,6 +190,8 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var cursorChannel;
|
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 () {
|
funcs.getCursorChannel = function () {
|
||||||
return cursorChannel;
|
return cursorChannel;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user