From a96e49d55a86653e9d47b853dc04d8e2c6168536 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 15 Nov 2017 16:56:50 +0100 Subject: [PATCH] Fix filepicker creating a new netflux network when initialized --- www/common/sframe-common-outer.js | 70 +++++++++++++++++------------- www/filepicker/app-filepicker.less | 1 + www/filepicker/inner.js | 2 - www/filepicker/main.js | 34 ++------------- 4 files changed, 46 insertions(+), 61 deletions(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index fcbb19d77..36d2fca78 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -15,6 +15,7 @@ define([ var Cryptpad; var Crypto; var Cryptget; + var SFrameChannel; var sframeChan; var FilePicker; var Messenger; @@ -37,12 +38,13 @@ define([ '/common/common-hash.js', '/common/common-util.js', '/common/common-realtime.js', - ], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, SFrameChannel, + ], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel, _FilePicker, _Messenger, _Messaging, _Notifier, _Hash, _Util, _Realtime) { CpNfOuter = _CpNfOuter; Cryptpad = _Cryptpad; Crypto = _Crypto; Cryptget = _Cryptget; + SFrameChannel = _SFrameChannel; FilePicker = _FilePicker; Messenger = _Messenger; Messaging = _Messaging; @@ -166,11 +168,40 @@ define([ sframeChan.event('EV_LOGOUT'); }); - sframeChan.on('Q_ANON_RPC_MESSAGE', function (data, cb) { - Cryptpad.anonRpcMsg(data.msg, data.content, function (err, response) { - cb({error: err, response: response}); + // Put in the following function the RPC queries that should also work in filepicker + var addCommonRpc = function (sframeChan) { + sframeChan.on('Q_ANON_RPC_MESSAGE', function (data, cb) { + Cryptpad.anonRpcMsg(data.msg, data.content, function (err, response) { + cb({error: err, response: response}); + }); }); - }); + + sframeChan.on('Q_GET_PIN_LIMIT_STATUS', function (data, cb) { + Cryptpad.isOverPinLimit(function (e, overLimit, limits) { + cb({ + error: e, + overLimit: overLimit, + limits: limits + }); + }); + }); + + sframeChan.on('Q_THUMBNAIL_GET', function (data, cb) { + Cryptpad.getThumbnail(data.key, function (e, data) { + cb({ + error: e, + data: data + }); + }); + }); + sframeChan.on('Q_THUMBNAIL_SET', function (data, cb) { + Cryptpad.setThumbnail(data.key, data.value, function (e) { + cb({error:e}); + }); + }); + + }; + addCommonRpc(sframeChan); var currentTitle; var currentTabTitle; @@ -221,16 +252,6 @@ define([ cb(); }); - sframeChan.on('Q_GET_PIN_LIMIT_STATUS', function (data, cb) { - Cryptpad.isOverPinLimit(function (e, overLimit, limits) { - cb({ - error: e, - overLimit: overLimit, - limits: limits - }); - }); - }); - sframeChan.on('Q_MOVE_TO_TRASH', function (data, cb) { cb = cb || $.noop; if (readOnly && hashes.editHash) { @@ -320,20 +341,6 @@ define([ }); }); - sframeChan.on('Q_THUMBNAIL_GET', function (data, cb) { - Cryptpad.getThumbnail(data.key, function (e, data) { - cb({ - error: e, - data: data - }); - }); - }); - sframeChan.on('Q_THUMBNAIL_SET', function (data, cb) { - Cryptpad.setThumbnail(data.key, data.value, function (e) { - cb({error:e}); - }); - }); - sframeChan.on('Q_SESSIONSTORAGE_PUT', function (data, cb) { sessionStorage[data.key] = data.value; cb(); @@ -405,6 +412,11 @@ define([ }; config.onFileUpload = onFileUpload; config.types = cfg; + config.addCommonRpc = addCommonRpc; + config.modules = { + Cryptpad: Cryptpad, + SFrameChannel: SFrameChannel + }; FP.$iframe = $('