From 0b34ceb0eba381a0ecc77916fcde57d32834e6d8 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Thu, 17 Aug 2017 17:34:08 +0200 Subject: [PATCH] Added RPC setPadTitleInDrive() --- www/common/sframe-common.js | 8 +++++--- www/common/sframe-protocol.js | 8 +++++++- www/pad2/main.js | 2 +- www/pad2/outer.js | 6 ++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 40759403b..75f563beb 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -20,8 +20,10 @@ define([ return ctx.cpNfInner.metadataMgr.getPrivateData().accountName; }; - funcs.setTitle = function (title /*:string*/, cb) { - + funcs.setPadTitleInDrive = function (title, cb) { + ctx.sframeChan.query('Q_SET_PAD_TITLE_IN_DRIVE', title, function (err) { + if (cb) { cb(err); } + }); }; Object.freeze(funcs); @@ -29,7 +31,7 @@ define([ nThen(function (waitFor) { SFrameChannel.create(window.top, waitFor(function (sfc) { ctx.sframeChan = sfc; })); // CpNfInner.start() should be here.... - }).nThen(function (waitFor) { + }).nThen(function () { cb(funcs); }); } }; diff --git a/www/common/sframe-protocol.js b/www/common/sframe-protocol.js index ea7557fc7..1893182ff 100644 --- a/www/common/sframe-protocol.js +++ b/www/common/sframe-protocol.js @@ -34,5 +34,11 @@ define({ // Called from the outside, this informs the inside whenever the user's data has been changed. // The argument is the object representing the content of the user profile minus the netfluxID // which changes per-reconnect. - 'EV_METADATA_UPDATE': true + 'EV_METADATA_UPDATE': true, + + // Takes one argument only, the title to set for the CURRENT pad which the user is looking at. + // This changes the pad title in drive ONLY, the pad title needs to be changed inside of the + // iframe and synchronized with the other users. This will not trigger a EV_METADATA_UPDATE + // because the metadata contained in EV_METADATA_UPDATE does not contain the pad title. + 'Q_SET_PAD_TITLE_IN_DRIVE': true, }); \ No newline at end of file diff --git a/www/pad2/main.js b/www/pad2/main.js index 8a46d12a4..6dc173da1 100644 --- a/www/pad2/main.js +++ b/www/pad2/main.js @@ -754,7 +754,7 @@ define([ $(waitFor(function () { Cryptpad.addLoadingScreen(); })); - SFCommon.create(waitFor(function (c) { common = c; })); + SFCommon.create(waitFor(function (c) { module.common = common = c; })); }).nThen(function (waitFor) { Ckeditor.config.toolbarCanCollapse = true; if (screen.height < 800) { diff --git a/www/pad2/outer.js b/www/pad2/outer.js index 2e7793cfc..035e02186 100644 --- a/www/pad2/outer.js +++ b/www/pad2/outer.js @@ -65,6 +65,12 @@ define([ } }); + sframeChan.on('Q_SET_PAD_TITLE_IN_DRIVE', function (newTitle, cb) { + Cryptpad.renamePad(newTitle, undefined, function (err) { + if (err) { cb('ERROR'); } else { cb(); } + }); + }); + CpNfOuter.start({ sframeChan: sframeChan, channel: secret.channel,