Fix filepicker creating a new netflux network when initialized
This commit is contained in:
parent
630ac45948
commit
a96e49d55a
@ -15,6 +15,7 @@ define([
|
|||||||
var Cryptpad;
|
var Cryptpad;
|
||||||
var Crypto;
|
var Crypto;
|
||||||
var Cryptget;
|
var Cryptget;
|
||||||
|
var SFrameChannel;
|
||||||
var sframeChan;
|
var sframeChan;
|
||||||
var FilePicker;
|
var FilePicker;
|
||||||
var Messenger;
|
var Messenger;
|
||||||
@ -37,12 +38,13 @@ define([
|
|||||||
'/common/common-hash.js',
|
'/common/common-hash.js',
|
||||||
'/common/common-util.js',
|
'/common/common-util.js',
|
||||||
'/common/common-realtime.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) {
|
_FilePicker, _Messenger, _Messaging, _Notifier, _Hash, _Util, _Realtime) {
|
||||||
CpNfOuter = _CpNfOuter;
|
CpNfOuter = _CpNfOuter;
|
||||||
Cryptpad = _Cryptpad;
|
Cryptpad = _Cryptpad;
|
||||||
Crypto = _Crypto;
|
Crypto = _Crypto;
|
||||||
Cryptget = _Cryptget;
|
Cryptget = _Cryptget;
|
||||||
|
SFrameChannel = _SFrameChannel;
|
||||||
FilePicker = _FilePicker;
|
FilePicker = _FilePicker;
|
||||||
Messenger = _Messenger;
|
Messenger = _Messenger;
|
||||||
Messaging = _Messaging;
|
Messaging = _Messaging;
|
||||||
@ -166,12 +168,41 @@ define([
|
|||||||
sframeChan.event('EV_LOGOUT');
|
sframeChan.event('EV_LOGOUT');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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) {
|
sframeChan.on('Q_ANON_RPC_MESSAGE', function (data, cb) {
|
||||||
Cryptpad.anonRpcMsg(data.msg, data.content, function (err, response) {
|
Cryptpad.anonRpcMsg(data.msg, data.content, function (err, response) {
|
||||||
cb({error: err, response: 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 currentTitle;
|
||||||
var currentTabTitle;
|
var currentTabTitle;
|
||||||
var setDocumentTitle = function () {
|
var setDocumentTitle = function () {
|
||||||
@ -221,16 +252,6 @@ define([
|
|||||||
cb();
|
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) {
|
sframeChan.on('Q_MOVE_TO_TRASH', function (data, cb) {
|
||||||
cb = cb || $.noop;
|
cb = cb || $.noop;
|
||||||
if (readOnly && hashes.editHash) {
|
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) {
|
sframeChan.on('Q_SESSIONSTORAGE_PUT', function (data, cb) {
|
||||||
sessionStorage[data.key] = data.value;
|
sessionStorage[data.key] = data.value;
|
||||||
cb();
|
cb();
|
||||||
@ -405,6 +412,11 @@ define([
|
|||||||
};
|
};
|
||||||
config.onFileUpload = onFileUpload;
|
config.onFileUpload = onFileUpload;
|
||||||
config.types = cfg;
|
config.types = cfg;
|
||||||
|
config.addCommonRpc = addCommonRpc;
|
||||||
|
config.modules = {
|
||||||
|
Cryptpad: Cryptpad,
|
||||||
|
SFrameChannel: SFrameChannel
|
||||||
|
};
|
||||||
FP.$iframe = $('<iframe>', {id: 'sbox-filePicker-iframe'}).appendTo($('body'));
|
FP.$iframe = $('<iframe>', {id: 'sbox-filePicker-iframe'}).appendTo($('body'));
|
||||||
FP.picker = FilePicker.create(config);
|
FP.picker = FilePicker.create(config);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -50,6 +50,7 @@
|
|||||||
img {
|
img {
|
||||||
max-width: 100px;
|
max-width: 100px;
|
||||||
max-height: 100px;
|
max-height: 100px;
|
||||||
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cp-filepicker-content-element-name {
|
.cp-filepicker-content-element-name {
|
||||||
|
|||||||
@ -149,8 +149,6 @@ define([
|
|||||||
updateContainer();
|
updateContainer();
|
||||||
};
|
};
|
||||||
sframeChan.on('EV_FILE_PICKER_REFRESH', function (newFilters) {
|
sframeChan.on('EV_FILE_PICKER_REFRESH', function (newFilters) {
|
||||||
console.log(Sortify(filters));
|
|
||||||
console.log(Sortify(newFilters));
|
|
||||||
if (Sortify(filters) !== Sortify(newFilters)) {
|
if (Sortify(filters) !== Sortify(newFilters)) {
|
||||||
$body.html('');
|
$body.html('');
|
||||||
filters = newFilters;
|
filters = newFilters;
|
||||||
|
|||||||
@ -38,25 +38,13 @@ define([
|
|||||||
window.addEventListener('message', onMsg);
|
window.addEventListener('message', onMsg);
|
||||||
}).nThen(function (/*waitFor*/) {
|
}).nThen(function (/*waitFor*/) {
|
||||||
var Cryptpad;
|
var Cryptpad;
|
||||||
var Crypto;
|
|
||||||
var Cryptget;
|
|
||||||
|
|
||||||
nThen(function (waitFor) {
|
nThen(function (waitFor) {
|
||||||
// Load #2, the loading screen is up so grab whatever you need...
|
Cryptpad = config.modules.Cryptpad;
|
||||||
require([
|
config.modules.SFrameChannel.create($('#sbox-filePicker-iframe')[0].contentWindow,
|
||||||
'/common/cryptpad-common.js',
|
waitFor(function (sfc) {
|
||||||
'/bower_components/chainpad-crypto/crypto.js',
|
|
||||||
'/common/cryptget.js',
|
|
||||||
'/common/sframe-channel.js',
|
|
||||||
], waitFor(function (_Cryptpad, _Crypto, _Cryptget, SFrameChannel) {
|
|
||||||
Cryptpad = _Cryptpad;
|
|
||||||
Crypto = _Crypto;
|
|
||||||
Cryptget = _Cryptget;
|
|
||||||
SFrameChannel.create($('#sbox-filePicker-iframe')[0].contentWindow, waitFor(function (sfc) {
|
|
||||||
sframeChan = sfc;
|
sframeChan = sfc;
|
||||||
}));
|
}));
|
||||||
Cryptpad.ready(waitFor());
|
|
||||||
}));
|
|
||||||
}).nThen(function () {
|
}).nThen(function () {
|
||||||
var proxy = Cryptpad.getProxy();
|
var proxy = Cryptpad.getProxy();
|
||||||
var updateMeta = function () {
|
var updateMeta = function () {
|
||||||
@ -94,21 +82,7 @@ define([
|
|||||||
sframeChan.onReg('EV_METADATA_UPDATE', updateMeta);
|
sframeChan.onReg('EV_METADATA_UPDATE', updateMeta);
|
||||||
proxy.on('change', 'settings', updateMeta);
|
proxy.on('change', 'settings', updateMeta);
|
||||||
|
|
||||||
sframeChan.on('Q_ANON_RPC_MESSAGE', function (data, cb) {
|
config.addCommonRpc(sframeChan);
|
||||||
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_GET_FILES_LIST', function (types, cb) {
|
sframeChan.on('Q_GET_FILES_LIST', function (types, cb) {
|
||||||
console.error("TODO: make sure Q_GET_FILES_LIST is only available from filepicker");
|
console.error("TODO: make sure Q_GET_FILES_LIST is only available from filepicker");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user