Remove Realtime and Messaging from common
This commit is contained in:
@@ -82,7 +82,7 @@ define([
|
||||
|
||||
friends[pubKey] = data;
|
||||
|
||||
Realtime.whenRealtimeSyncs(common, common.getRealtime(), function () {
|
||||
Realtime.whenRealtimeSyncs(common.getRealtime(), function () {
|
||||
cb();
|
||||
common.pinPads([data.channel], function (e) {
|
||||
if (e) { console.error(e); }
|
||||
|
||||
@@ -50,21 +50,6 @@ define([
|
||||
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) {
|
||||
return channel.messages.some(function (message) {
|
||||
return message[0] === sig;
|
||||
|
||||
@@ -16,7 +16,7 @@ define([
|
||||
/*
|
||||
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') {
|
||||
return void console.error('improper use of this function');
|
||||
}
|
||||
@@ -29,7 +29,7 @@ define([
|
||||
}, 0);
|
||||
};
|
||||
|
||||
common.beginDetectingInfiniteSpinner = function (Cryptpad, realtime) {
|
||||
common.beginDetectingInfiniteSpinner = function (realtime) {
|
||||
if (intr) { return; }
|
||||
intr = window.setInterval(function () {
|
||||
var l;
|
||||
|
||||
@@ -98,22 +98,21 @@ define([
|
||||
//common.createInviteUrl = Hash.createInviteUrl;
|
||||
|
||||
// Messaging
|
||||
common.addDirectMessageHandler = Messaging.addDirectMessageHandler;
|
||||
common.inviteFromUserlist = Messaging.inviteFromUserlist;
|
||||
common.getFriendList = Messaging.getFriendList;
|
||||
common.getFriendChannelsList = Messaging.getFriendChannelsList;
|
||||
common.createData = Messaging.createData;
|
||||
common.getPendingInvites = Messaging.getPending;
|
||||
common.getLatestMessages = Messaging.getLatestMessages;
|
||||
//common.addDirectMessageHandler = Messaging.addDirectMessageHandler;
|
||||
//common.inviteFromUserlist = Messaging.inviteFromUserlist;
|
||||
//common.getFriendList = Messaging.getFriendList;
|
||||
//common.getFriendChannelsList = Messaging.getFriendChannelsList;
|
||||
//common.createData = Messaging.createData;
|
||||
//common.getPendingInvites = Messaging.getPending;
|
||||
//common.getLatestMessages = Messaging.getLatestMessages;
|
||||
|
||||
// Realtime
|
||||
// REFACTOR: common is not needed anymore so we should just pull common-reealtime directly
|
||||
var whenRealtimeSyncs = common.whenRealtimeSyncs = function (realtime, cb) {
|
||||
Realtime.whenRealtimeSyncs(common, realtime, cb);
|
||||
};
|
||||
common.beginDetectingInfiniteSpinner = function (realtime) {
|
||||
Realtime.beginDetectingInfiniteSpinner(common, realtime);
|
||||
};
|
||||
//var whenRealtimeSyncs = common.whenRealtimeSyncs = function (realtime, cb) {
|
||||
//Realtime.whenRealtimeSyncs(common, realtime, cb);
|
||||
//};
|
||||
//common.beginDetectingInfiniteSpinner = function (realtime) {
|
||||
//Realtime.beginDetectingInfiniteSpinner(common, realtime);
|
||||
//};
|
||||
|
||||
var getStore = common.getStore = function () {
|
||||
if (store) { return store; }
|
||||
@@ -429,7 +428,7 @@ define([
|
||||
if (getProxy()) {
|
||||
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) {
|
||||
getStore().setAttribute(attr, value, function (err, data) {
|
||||
@@ -814,7 +813,7 @@ define([
|
||||
}
|
||||
|
||||
if (getProxy().friends) {
|
||||
var fList = common.getFriendChannelsList(common);
|
||||
var fList = Messaging.getFriendChannelsList(common);
|
||||
list = list.concat(fList);
|
||||
}
|
||||
|
||||
@@ -1018,7 +1017,7 @@ define([
|
||||
var n = getNetwork();
|
||||
var r = getRealtime();
|
||||
if (n && r) {
|
||||
whenRealtimeSyncs(r, function () {
|
||||
Realtime.whenRealtimeSyncs(r, function () {
|
||||
n.disconnect();
|
||||
cb();
|
||||
});
|
||||
@@ -1037,7 +1036,7 @@ define([
|
||||
Cryptput(hash, data.toSave, function (e) {
|
||||
if (e) { throw new Error(e); }
|
||||
common.addTemplate(makePad(href, data.title));
|
||||
whenRealtimeSyncs(getStore().getProxy().info.realtime, function () {
|
||||
Realtime.whenRealtimeSyncs(getRealtime(), function () {
|
||||
cb();
|
||||
});
|
||||
});
|
||||
@@ -1185,7 +1184,7 @@ define([
|
||||
Nthen(function (waitFor) {
|
||||
Store.ready(waitFor(function (err, storeObj) {
|
||||
store = common.store = env.store = storeObj;
|
||||
common.addDirectMessageHandler(common);
|
||||
Messaging.addDirectMessageHandler(common);
|
||||
proxy = getProxy();
|
||||
network = getNetwork();
|
||||
network.on('disconnect', function () {
|
||||
|
||||
@@ -18,6 +18,7 @@ define([
|
||||
var sframeChan;
|
||||
var FilePicker;
|
||||
var Messenger;
|
||||
var Messaging;
|
||||
var Notifier;
|
||||
var Utils = {};
|
||||
|
||||
@@ -31,18 +32,20 @@ define([
|
||||
'/common/sframe-channel.js',
|
||||
'/filepicker/main.js',
|
||||
'/common/common-messenger.js',
|
||||
'/common/common-messaging.js',
|
||||
'/common/common-notifier.js',
|
||||
'/common/common-hash.js',
|
||||
'/common/common-util.js',
|
||||
'/common/common-realtime.js',
|
||||
], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, SFrameChannel,
|
||||
_FilePicker, _Messenger, _Notifier, _Hash, _Util, _Realtime) {
|
||||
_FilePicker, _Messenger, _Messaging, _Notifier, _Hash, _Util, _Realtime) {
|
||||
CpNfOuter = _CpNfOuter;
|
||||
Cryptpad = _Cryptpad;
|
||||
Crypto = _Crypto;
|
||||
Cryptget = _Cryptget;
|
||||
FilePicker = _FilePicker;
|
||||
Messenger = _Messenger;
|
||||
Messaging = _Messaging;
|
||||
Notifier = _Notifier;
|
||||
Utils.Hash = _Hash;
|
||||
Utils.Util = _Util;
|
||||
@@ -246,7 +249,7 @@ define([
|
||||
});
|
||||
|
||||
sframeChan.on('Q_SEND_FRIEND_REQUEST', function (netfluxId, cb) {
|
||||
Cryptpad.inviteFromUserlist(Cryptpad, netfluxId);
|
||||
Messaging.inviteFromUserlist(Cryptpad, netfluxId);
|
||||
cb();
|
||||
});
|
||||
Cryptpad.onFriendRequest = function (confirmText, cb) {
|
||||
|
||||
Reference in New Issue
Block a user