Remove Realtime and Messaging from common
This commit is contained in:
parent
30c8c253dd
commit
5a2afb5c95
@ -3,14 +3,14 @@ define([
|
|||||||
'/customize/application_config.js',
|
'/customize/application_config.js',
|
||||||
'/common/cryptpad-common.js',
|
'/common/cryptpad-common.js',
|
||||||
'/common/common-interface.js',
|
'/common/common-interface.js',
|
||||||
], function ($, Config, Cryptpad, UI) {
|
'/common/common-realtime.js',
|
||||||
|
'/customize/messages.js',
|
||||||
|
], function ($, Config, Cryptpad, UI, Realtime, Messages) {
|
||||||
|
|
||||||
window.APP = {
|
window.APP = {
|
||||||
Cryptpad: Cryptpad,
|
Cryptpad: Cryptpad,
|
||||||
};
|
};
|
||||||
|
|
||||||
var Messages = Cryptpad.Messages;
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
var $main = $('#mainBlock');
|
var $main = $('#mainBlock');
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ define([
|
|||||||
proxy.edPrivate = result.edPrivate;
|
proxy.edPrivate = result.edPrivate;
|
||||||
proxy.edPublic = result.edPublic;
|
proxy.edPublic = result.edPublic;
|
||||||
|
|
||||||
Cryptpad.whenRealtimeSyncs(result.realtime, function () {
|
Realtime.whenRealtimeSyncs(result.realtime, function () {
|
||||||
Cryptpad.login(result.userHash, result.userName, function () {
|
Cryptpad.login(result.userHash, result.userName, function () {
|
||||||
document.location.href = '/drive/';
|
document.location.href = '/drive/';
|
||||||
});
|
});
|
||||||
|
|||||||
@ -82,7 +82,7 @@ define([
|
|||||||
|
|
||||||
friends[pubKey] = data;
|
friends[pubKey] = data;
|
||||||
|
|
||||||
Realtime.whenRealtimeSyncs(common, common.getRealtime(), function () {
|
Realtime.whenRealtimeSyncs(common.getRealtime(), function () {
|
||||||
cb();
|
cb();
|
||||||
common.pinPads([data.channel], function (e) {
|
common.pinPads([data.channel], function (e) {
|
||||||
if (e) { console.error(e); }
|
if (e) { console.error(e); }
|
||||||
|
|||||||
@ -50,21 +50,6 @@ define([
|
|||||||
return proxy.friends;
|
return proxy.friends;
|
||||||
};
|
};
|
||||||
|
|
||||||
var eachFriend = function (friends, cb) {
|
|
||||||
Object.keys(friends).forEach(function (id) {
|
|
||||||
if (id === 'me') { return; }
|
|
||||||
cb(friends[id], id, friends);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Msg.getFriendChannelsList = function (proxy) {
|
|
||||||
var list = [];
|
|
||||||
eachFriend(proxy, function (friend) {
|
|
||||||
list.push(friend.channel);
|
|
||||||
});
|
|
||||||
return list;
|
|
||||||
};
|
|
||||||
|
|
||||||
var msgAlreadyKnown = function (channel, sig) {
|
var msgAlreadyKnown = function (channel, sig) {
|
||||||
return channel.messages.some(function (message) {
|
return channel.messages.some(function (message) {
|
||||||
return message[0] === sig;
|
return message[0] === sig;
|
||||||
|
|||||||
@ -16,7 +16,7 @@ define([
|
|||||||
/*
|
/*
|
||||||
TODO make this not blow up when disconnected or lagging...
|
TODO make this not blow up when disconnected or lagging...
|
||||||
*/
|
*/
|
||||||
common.whenRealtimeSyncs = function (Cryptpad, realtime, cb) {
|
common.whenRealtimeSyncs = function (realtime, cb) {
|
||||||
if (typeof(realtime.getAuthDoc) !== 'function') {
|
if (typeof(realtime.getAuthDoc) !== 'function') {
|
||||||
return void console.error('improper use of this function');
|
return void console.error('improper use of this function');
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ define([
|
|||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
common.beginDetectingInfiniteSpinner = function (Cryptpad, realtime) {
|
common.beginDetectingInfiniteSpinner = function (realtime) {
|
||||||
if (intr) { return; }
|
if (intr) { return; }
|
||||||
intr = window.setInterval(function () {
|
intr = window.setInterval(function () {
|
||||||
var l;
|
var l;
|
||||||
|
|||||||
@ -98,22 +98,21 @@ define([
|
|||||||
//common.createInviteUrl = Hash.createInviteUrl;
|
//common.createInviteUrl = Hash.createInviteUrl;
|
||||||
|
|
||||||
// Messaging
|
// Messaging
|
||||||
common.addDirectMessageHandler = Messaging.addDirectMessageHandler;
|
//common.addDirectMessageHandler = Messaging.addDirectMessageHandler;
|
||||||
common.inviteFromUserlist = Messaging.inviteFromUserlist;
|
//common.inviteFromUserlist = Messaging.inviteFromUserlist;
|
||||||
common.getFriendList = Messaging.getFriendList;
|
//common.getFriendList = Messaging.getFriendList;
|
||||||
common.getFriendChannelsList = Messaging.getFriendChannelsList;
|
//common.getFriendChannelsList = Messaging.getFriendChannelsList;
|
||||||
common.createData = Messaging.createData;
|
//common.createData = Messaging.createData;
|
||||||
common.getPendingInvites = Messaging.getPending;
|
//common.getPendingInvites = Messaging.getPending;
|
||||||
common.getLatestMessages = Messaging.getLatestMessages;
|
//common.getLatestMessages = Messaging.getLatestMessages;
|
||||||
|
|
||||||
// Realtime
|
// Realtime
|
||||||
// REFACTOR: common is not needed anymore so we should just pull common-reealtime directly
|
//var whenRealtimeSyncs = common.whenRealtimeSyncs = function (realtime, cb) {
|
||||||
var whenRealtimeSyncs = common.whenRealtimeSyncs = function (realtime, cb) {
|
//Realtime.whenRealtimeSyncs(common, realtime, cb);
|
||||||
Realtime.whenRealtimeSyncs(common, realtime, cb);
|
//};
|
||||||
};
|
//common.beginDetectingInfiniteSpinner = function (realtime) {
|
||||||
common.beginDetectingInfiniteSpinner = function (realtime) {
|
//Realtime.beginDetectingInfiniteSpinner(common, realtime);
|
||||||
Realtime.beginDetectingInfiniteSpinner(common, realtime);
|
//};
|
||||||
};
|
|
||||||
|
|
||||||
var getStore = common.getStore = function () {
|
var getStore = common.getStore = function () {
|
||||||
if (store) { return store; }
|
if (store) { return store; }
|
||||||
@ -429,7 +428,7 @@ define([
|
|||||||
if (getProxy()) {
|
if (getProxy()) {
|
||||||
getProxy()[common.displayNameKey] = value;
|
getProxy()[common.displayNameKey] = value;
|
||||||
}
|
}
|
||||||
if (typeof cb === "function") { whenRealtimeSyncs(getRealtime(), cb); }
|
if (typeof cb === "function") { Realtime.whenRealtimeSyncs(getRealtime(), cb); }
|
||||||
};
|
};
|
||||||
common.setAttribute = function (attr, value, cb) {
|
common.setAttribute = function (attr, value, cb) {
|
||||||
getStore().setAttribute(attr, value, function (err, data) {
|
getStore().setAttribute(attr, value, function (err, data) {
|
||||||
@ -814,7 +813,7 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getProxy().friends) {
|
if (getProxy().friends) {
|
||||||
var fList = common.getFriendChannelsList(common);
|
var fList = Messaging.getFriendChannelsList(common);
|
||||||
list = list.concat(fList);
|
list = list.concat(fList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1018,7 +1017,7 @@ define([
|
|||||||
var n = getNetwork();
|
var n = getNetwork();
|
||||||
var r = getRealtime();
|
var r = getRealtime();
|
||||||
if (n && r) {
|
if (n && r) {
|
||||||
whenRealtimeSyncs(r, function () {
|
Realtime.whenRealtimeSyncs(r, function () {
|
||||||
n.disconnect();
|
n.disconnect();
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
@ -1037,7 +1036,7 @@ define([
|
|||||||
Cryptput(hash, data.toSave, function (e) {
|
Cryptput(hash, data.toSave, function (e) {
|
||||||
if (e) { throw new Error(e); }
|
if (e) { throw new Error(e); }
|
||||||
common.addTemplate(makePad(href, data.title));
|
common.addTemplate(makePad(href, data.title));
|
||||||
whenRealtimeSyncs(getStore().getProxy().info.realtime, function () {
|
Realtime.whenRealtimeSyncs(getRealtime(), function () {
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1185,7 +1184,7 @@ define([
|
|||||||
Nthen(function (waitFor) {
|
Nthen(function (waitFor) {
|
||||||
Store.ready(waitFor(function (err, storeObj) {
|
Store.ready(waitFor(function (err, storeObj) {
|
||||||
store = common.store = env.store = storeObj;
|
store = common.store = env.store = storeObj;
|
||||||
common.addDirectMessageHandler(common);
|
Messaging.addDirectMessageHandler(common);
|
||||||
proxy = getProxy();
|
proxy = getProxy();
|
||||||
network = getNetwork();
|
network = getNetwork();
|
||||||
network.on('disconnect', function () {
|
network.on('disconnect', function () {
|
||||||
|
|||||||
@ -18,6 +18,7 @@ define([
|
|||||||
var sframeChan;
|
var sframeChan;
|
||||||
var FilePicker;
|
var FilePicker;
|
||||||
var Messenger;
|
var Messenger;
|
||||||
|
var Messaging;
|
||||||
var Notifier;
|
var Notifier;
|
||||||
var Utils = {};
|
var Utils = {};
|
||||||
|
|
||||||
@ -31,18 +32,20 @@ define([
|
|||||||
'/common/sframe-channel.js',
|
'/common/sframe-channel.js',
|
||||||
'/filepicker/main.js',
|
'/filepicker/main.js',
|
||||||
'/common/common-messenger.js',
|
'/common/common-messenger.js',
|
||||||
|
'/common/common-messaging.js',
|
||||||
'/common/common-notifier.js',
|
'/common/common-notifier.js',
|
||||||
'/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, _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;
|
||||||
FilePicker = _FilePicker;
|
FilePicker = _FilePicker;
|
||||||
Messenger = _Messenger;
|
Messenger = _Messenger;
|
||||||
|
Messaging = _Messaging;
|
||||||
Notifier = _Notifier;
|
Notifier = _Notifier;
|
||||||
Utils.Hash = _Hash;
|
Utils.Hash = _Hash;
|
||||||
Utils.Util = _Util;
|
Utils.Util = _Util;
|
||||||
@ -246,7 +249,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
sframeChan.on('Q_SEND_FRIEND_REQUEST', function (netfluxId, cb) {
|
sframeChan.on('Q_SEND_FRIEND_REQUEST', function (netfluxId, cb) {
|
||||||
Cryptpad.inviteFromUserlist(Cryptpad, netfluxId);
|
Messaging.inviteFromUserlist(Cryptpad, netfluxId);
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
Cryptpad.onFriendRequest = function (confirmText, cb) {
|
Cryptpad.onFriendRequest = function (confirmText, cb) {
|
||||||
|
|||||||
@ -3,9 +3,10 @@ define([
|
|||||||
'/common/cryptpad-common.js',
|
'/common/cryptpad-common.js',
|
||||||
'/common/login.js',
|
'/common/login.js',
|
||||||
'/common/common-interface.js',
|
'/common/common-interface.js',
|
||||||
|
'/common/common-realtime.js',
|
||||||
|
|
||||||
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
||||||
], function ($, Cryptpad, Login, UI) {
|
], function ($, Cryptpad, Login, UI, Realtime) {
|
||||||
$(function () {
|
$(function () {
|
||||||
var $main = $('#mainBlock');
|
var $main = $('#mainBlock');
|
||||||
var Messages = Cryptpad.Messages;
|
var Messages = Cryptpad.Messages;
|
||||||
@ -83,7 +84,7 @@ define([
|
|||||||
proxy.curvePublic = result.curvePublic;
|
proxy.curvePublic = result.curvePublic;
|
||||||
|
|
||||||
Cryptpad.feedback('LOGIN', true);
|
Cryptpad.feedback('LOGIN', true);
|
||||||
Cryptpad.whenRealtimeSyncs(result.realtime, function() {
|
Realtime.whenRealtimeSyncs(result.realtime, function() {
|
||||||
Cryptpad.login(result.userHash, result.userName, function () {
|
Cryptpad.login(result.userHash, result.userName, function () {
|
||||||
hashing = false;
|
hashing = false;
|
||||||
if (sessionStorage.redirectTo) {
|
if (sessionStorage.redirectTo) {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ define([
|
|||||||
'/common/sframe-common.js',
|
'/common/sframe-common.js',
|
||||||
'/common/common-util.js',
|
'/common/common-util.js',
|
||||||
'/common/common-interface.js',
|
'/common/common-interface.js',
|
||||||
|
'/common/common-realtime.js',
|
||||||
'/bower_components/marked/marked.min.js',
|
'/bower_components/marked/marked.min.js',
|
||||||
'cm/lib/codemirror',
|
'cm/lib/codemirror',
|
||||||
'cm/mode/markdown/markdown',
|
'cm/mode/markdown/markdown',
|
||||||
@ -28,6 +29,7 @@ define([
|
|||||||
SFCommon,
|
SFCommon,
|
||||||
Util,
|
Util,
|
||||||
UI,
|
UI,
|
||||||
|
Realtime,
|
||||||
Marked,
|
Marked,
|
||||||
CodeMirror
|
CodeMirror
|
||||||
)
|
)
|
||||||
@ -225,7 +227,7 @@ define([
|
|||||||
}
|
}
|
||||||
var setValue = function (value, cb) {
|
var setValue = function (value, cb) {
|
||||||
APP.lm.proxy.name = value;
|
APP.lm.proxy.name = value;
|
||||||
Cryptpad.whenRealtimeSyncs(APP.lm.realtime, cb);
|
Realtime.whenRealtimeSyncs(APP.lm.realtime, cb);
|
||||||
};
|
};
|
||||||
createEditableInput($block, DISPLAYNAME_ID, placeholder, getValue, setValue, Messages.anonymous);
|
createEditableInput($block, DISPLAYNAME_ID, placeholder, getValue, setValue, Messages.anonymous);
|
||||||
};
|
};
|
||||||
@ -251,7 +253,7 @@ define([
|
|||||||
}
|
}
|
||||||
var setValue = function (value, cb) {
|
var setValue = function (value, cb) {
|
||||||
APP.lm.proxy.url = value;
|
APP.lm.proxy.url = value;
|
||||||
Cryptpad.whenRealtimeSyncs(APP.lm.realtime, cb);
|
Realtime.whenRealtimeSyncs(APP.lm.realtime, cb);
|
||||||
};
|
};
|
||||||
var placeholder = Messages.profile_urlPlaceholder;
|
var placeholder = Messages.profile_urlPlaceholder;
|
||||||
createEditableInput($block, LINK_ID, placeholder, getValue, setValue);
|
createEditableInput($block, LINK_ID, placeholder, getValue, setValue);
|
||||||
@ -370,7 +372,7 @@ define([
|
|||||||
$spinner.show();
|
$spinner.show();
|
||||||
var val = editor.getValue();
|
var val = editor.getValue();
|
||||||
APP.lm.proxy.description = val;
|
APP.lm.proxy.description = val;
|
||||||
Cryptpad.whenRealtimeSyncs(APP.lm.realtime, function () {
|
Realtime.whenRealtimeSyncs(APP.lm.realtime, function () {
|
||||||
$ok.show();
|
$ok.show();
|
||||||
$spinner.hide();
|
$spinner.hide();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,9 +6,10 @@ define([
|
|||||||
'/common/credential.js', // preloaded for login.js
|
'/common/credential.js', // preloaded for login.js
|
||||||
'/common/common-interface.js',
|
'/common/common-interface.js',
|
||||||
'/common/common-util.js',
|
'/common/common-util.js',
|
||||||
|
'/common/common-realtime.js',
|
||||||
|
|
||||||
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
||||||
], function ($, Login, Cryptpad, Test, Cred, UI, Util) {
|
], function ($, Login, Cryptpad, Test, Cred, UI, Util, Realtime) {
|
||||||
var Messages = Cryptpad.Messages;
|
var Messages = Cryptpad.Messages;
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
@ -66,7 +67,7 @@ define([
|
|||||||
|
|
||||||
Cryptpad.feedback('REGISTRATION', true);
|
Cryptpad.feedback('REGISTRATION', true);
|
||||||
|
|
||||||
Cryptpad.whenRealtimeSyncs(result.realtime, function () {
|
Realtime.whenRealtimeSyncs(result.realtime, function () {
|
||||||
Cryptpad.login(result.userHash, result.userName, function () {
|
Cryptpad.login(result.userHash, result.userName, function () {
|
||||||
registering = false;
|
registering = false;
|
||||||
if (sessionStorage.redirectTo) {
|
if (sessionStorage.redirectTo) {
|
||||||
|
|||||||
@ -47,7 +47,7 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
var addRpc = function (sframeChan, Cryptpad) {
|
var addRpc = function (sframeChan, Cryptpad, Utils) {
|
||||||
sframeChan.on('Q_THUMBNAIL_CLEAR', function (d, cb) {
|
sframeChan.on('Q_THUMBNAIL_CLEAR', function (d, cb) {
|
||||||
Cryptpad.clearThumbnail(function (err, data) {
|
Cryptpad.clearThumbnail(function (err, data) {
|
||||||
cb({err:err, data:data});
|
cb({err:err, data:data});
|
||||||
@ -69,7 +69,7 @@ define([
|
|||||||
var proxy = Cryptpad.getProxy();
|
var proxy = Cryptpad.getProxy();
|
||||||
var realtime = Cryptpad.getRealtime();
|
var realtime = Cryptpad.getRealtime();
|
||||||
proxy.drive = Cryptpad.getStore().getEmptyObject();
|
proxy.drive = Cryptpad.getStore().getEmptyObject();
|
||||||
Cryptpad.whenRealtimeSyncs(realtime, cb);
|
Utils.Realtime.whenRealtimeSyncs(realtime, cb);
|
||||||
});
|
});
|
||||||
sframeChan.on('Q_SETTINGS_LOGOUT', function (data, cb) {
|
sframeChan.on('Q_SETTINGS_LOGOUT', function (data, cb) {
|
||||||
var proxy = Cryptpad.getProxy();
|
var proxy = Cryptpad.getProxy();
|
||||||
@ -77,7 +77,7 @@ define([
|
|||||||
var token = Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);
|
var token = Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);
|
||||||
localStorage.setItem('loginToken', token);
|
localStorage.setItem('loginToken', token);
|
||||||
proxy.loginToken = token;
|
proxy.loginToken = token;
|
||||||
Cryptpad.whenRealtimeSyncs(realtime, cb);
|
Utils.Realtime.whenRealtimeSyncs(realtime, cb);
|
||||||
});
|
});
|
||||||
sframeChan.on('Q_SETTINGS_IMPORT_LOCAL', function (data, cb) {
|
sframeChan.on('Q_SETTINGS_IMPORT_LOCAL', function (data, cb) {
|
||||||
var proxyData = Cryptpad.getStore().getProxy();
|
var proxyData = Cryptpad.getStore().getProxy();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user