Refactor messenger to use commands from UI to store

This commit is contained in:
yflory
2018-11-27 16:55:56 +01:00
parent cc3e6f3924
commit ca45ff31d1
10 changed files with 158 additions and 480 deletions

View File

@@ -62,12 +62,6 @@ define([
Msg.messenger = function (store) {
var messenger = {
handlers: {
message: [],
join: [],
leave: [],
update: [],
friend: [],
unfriend: [],
event: []
},
range_requests: {},
@@ -136,12 +130,12 @@ define([
delete messenger.range_requests[txid];
};
messenger.getMoreHistory = function (chanId, hash, count, cb) {
var getMoreHistory = function (chanId, hash, count, cb) {
if (typeof(cb) !== 'function') { return; }
if (typeof(hash) !== 'string') {
// Channel is empty!
return void cb(void 0, []);
return void cb([]);
}
var chan = getChannel(chanId);
@@ -189,17 +183,17 @@ define([
}
};*/
messenger.setChannelHead = function (id, hash, cb) {
var setChannelHead = function (id, hash, cb) {
var channel = getChannel(id);
if (channel.isFriendChat) {
var friend = getFriendFromChannel(id);
if (!friend) { return void cb('NO_SUCH_FRIEND'); }
if (!friend) { return void cb({error: 'NO_SUCH_FRIEND'}); }
friend.lastKnownHash = hash;
} else if (channel.isPadChat) {
// Nothing to do
} else {
// TODO room
return void cb('NOT_IMPLEMENTED');
return void cb({error: 'NOT_IMPLEMENTED'});
}
cb();
};
@@ -217,8 +211,10 @@ define([
}
});
eachHandler('update', function (f) {
f(clone(data), types, channel);
emit('UPDATE_DATA', {
info: clone(data),
types: types,
channel: channel
});
};
@@ -263,8 +259,9 @@ define([
if (parsed[2] !== sender || !parsed[1]) { return; }
channel.mapId[sender] = parsed[1];
checkFriendData(parsed[1].curvePublic, parsed[1], channel.id);
eachHandler('join', function (f) {
f(parsed[1], channel.id);
emit('JOIN', {
info: parsed[1],
id: channel.id
});
if (parsed[0] !== Types.mapId) { return; } // Don't send your key if it's already an ACK
@@ -321,9 +318,7 @@ define([
channel.messages.push(res);
if (!joining[channel.id]) {
// Channel is ready
eachHandler('message', function (f) {
f(res);
});
emit('MESSAGE', res);
}
return true;
@@ -342,8 +337,9 @@ define([
removeFromFriendList(curvePublic, function () {
channel.wc.leave(Types.unfriend);
delete channels[channel.id];
eachHandler('unfriend', function (f) {
f(curvePublic, false);
emit('UNFRIEND', {
curvePublic: curvePublic,
fromMe: false
});
});
return;
@@ -380,8 +376,10 @@ define([
console.error(err);
});
});
eachHandler('update', function (f) {
f(myData, ['displayName', 'profile', 'avatar']);
emit('UPDATE', {
info: myData,
types: ['displayName', 'profile', 'avatar'],
});
friends.me = myData;
}
@@ -490,7 +488,7 @@ define([
});
orderMessages(channel, decrypted);
req.cb(void 0, decrypted);
req.cb(decrypted);
return deleteRangeRequest(txid);
} else {
console.log(parsed);
@@ -505,14 +503,14 @@ define([
// Error in initial history
// History cleared while we're in the channel
if (parsed.error === 'ECLEARED') {
messenger.setChannelHead(parsed.channel, '', function () {});
setChannelHead(parsed.channel, '', function () {});
emit('CLEAR_CHANNEL', parsed.channel);
return;
}
// History cleared while we were offline
// ==> we asked for an invalid last known hash
if (parsed.error && parsed.error === "EINVAL") {
messenger.setChannelHead(parsed.channel, '', function () {
setChannelHead(parsed.channel, '', function () {
getChannelMessagesSince(getChannel(parsed.channel), {}, {});
});
return;
@@ -551,19 +549,19 @@ define([
onDirectMessage(msg, sender);
});
messenger.removeFriend = function (curvePublic, cb) {
var removeFriend = function (curvePublic, cb) {
if (typeof(cb) !== 'function') { throw new Error('NO_CALLBACK'); }
var data = getFriend(proxy, curvePublic);
if (!data) {
// friend is not valid
console.error('friend is not valid');
return void cb('INVALID_FRIEND');
return void cb({error: 'INVALID_FRIEND'});
}
var channel = channels[data.channel];
if (!channel) {
return void cb("NO_SUCH_CHANNEL");
return void cb({error: "NO_SUCH_CHANNEL"});
}
if (!network.webChannels.some(function (wc) {
@@ -580,17 +578,18 @@ define([
channel.wc.bcast(cryptMsg).then(function () {
removeFromFriendList(curvePublic, function () {
delete channels[channel.id];
eachHandler('unfriend', function (f) {
f(curvePublic, true);
emit('UNFRIEND', {
curvePublic: curvePublic,
fromMe: true
});
cb();
});
}, function (err) {
console.error(err);
cb(err);
cb({error: err});
});
} catch (e) {
cb(e);
cb({error: e});
}
};
@@ -644,8 +643,9 @@ define([
})) { return; }
// Send the notification
eachHandler('leave', function (f) {
f(otherData, channel.id);
emit('LEAVE', {
info: otherData,
id: channel.id
});
};
@@ -689,27 +689,13 @@ define([
}));
};
/*messenger.openFriendChannel = function (curvePublic, cb) {
if (typeof(curvePublic) !== 'string') { return void cb('INVALID_ID'); }
if (typeof(cb) !== 'function') { throw new Error('expected callback'); }
var friend = clone(friends[curvePublic]);
if (typeof(friend) !== 'object') {
return void cb('NO_FRIEND_DATA');
}
var channel = friend.channel;
if (!channel) { return void cb('E_NO_CHANNEL'); }
joining[channel] = cb;
openFriendChannel(friend, curvePublic);
};*/
messenger.sendMessage = function (id, payload, cb) {
var sendMessage = function (id, payload, cb) {
var channel = getChannel(id);
if (!channel) { return void cb('NO_CHANNEL'); }
if (!channel) { return void cb({error: 'NO_CHANNEL'}); }
if (!network.webChannels.some(function (wc) {
if (wc.id === channel.wc.id) { return true; }
})) {
return void cb('NO_SUCH_CHANNEL');
return void cb({error: 'NO_SUCH_CHANNEL'});
}
var msg = [Types.message, proxy.curvePublic, +new Date(), payload];
@@ -725,11 +711,11 @@ define([
pushMsg(channel, cryptMsg);
cb();
}, function (err) {
cb(err);
cb({error: err});
});
};
messenger.getStatus = function (chanId, cb) {
var getStatus = function (chanId, cb) {
// Display green status if one member is not me
var channel = getChannel(chanId);
if (!channel) { return void cb('NO_SUCH_CHANNEL'); }
@@ -738,26 +724,11 @@ define([
if (!data) { return false; }
return data.curvePublic !== proxy.curvePublic;
});
cb(void 0, online);
cb(online);
};
messenger.getFriendInfo = function (channel, cb) {
setTimeout(function () {
var friend;
for (var k in friends) {
if (friends[k].channel === channel) {
friend = friends[k];
break;
}
}
if (!friend) { return void cb('NO_SUCH_FRIEND'); }
// this clone will be redundant when ui uses postmessage
cb(void 0, clone(friend));
});
};
messenger.getMyInfo = function (cb) {
cb(void 0, {
var getMyInfo = function (cb) {
cb({
curvePublic: proxy.curvePublic,
displayName: proxy[Constants.displayNameKey]
});
@@ -792,8 +763,8 @@ define([
var channel = friend.channel;
if (!channel) { return; }
loadFriend(friend, function () {
eachHandler('friend', function (f) {
f(curvePublic);
emit('FRIEND', {
curvePublic: curvePublic,
});
});
return;
@@ -810,8 +781,9 @@ define([
var channel = channels[o];
channel.wc.leave(Types.unfriend);
delete channels[channel.id];
eachHandler('unfriend', function (f) {
f(curvePublic, true);
emit('UNFRIEND', {
curvePublic: curvePublic,
fromMe: true
});
});
@@ -822,8 +794,8 @@ define([
var channel = friend.channel;
if (!channel) { return; }
loadFriend(friend, function () {
eachHandler('friend', function (f) {
f(friend.curvePublic);
emit('FRIEND', {
curvePublic: friend.curvePublic,
});
});
};
@@ -982,6 +954,24 @@ define([
if (cmd === 'OPEN_PAD_CHAT') {
return void openPadChat(data, cb);
}
if (cmd === 'GET_MY_INFO') {
return void getMyInfo(cb);
}
if (cmd === 'REMOVE_FRIEND') {
return void removeFriend(data, cb);
}
if (cmd === 'GET_STATUS') {
return void getStatus(data, cb);
}
if (cmd === 'GET_MORE_HISTORY') {
return void getMoreHistory(data.id, data.sig, data.count, cb);
}
if (cmd === 'SEND_MESSAGE') {
return void sendMessage(data.id, data.content, cb);
}
if (cmd === 'SET_CHANNEL_HEAD') {
return void setChannelHead(data.id, data.sig, cb);
}
};
Object.freeze(messenger);

View File

@@ -619,45 +619,10 @@ define([
// Messenger
var messenger = common.messenger = {};
messenger.getFriendList = function (cb) {
postMessage("CONTACTS_GET_FRIEND_LIST", null, cb);
};
messenger.getMyInfo = function (cb) {
postMessage("CONTACTS_GET_MY_INFO", null, cb);
};
messenger.getFriendInfo = function (curvePublic, cb) {
postMessage("CONTACTS_GET_FRIEND_INFO", curvePublic, cb);
};
messenger.removeFriend = function (curvePublic, cb) {
postMessage("CONTACTS_REMOVE_FRIEND", curvePublic, cb);
};
messenger.openFriendChannel = function (curvePublic, cb) {
postMessage("CONTACTS_OPEN_FRIEND_CHANNEL", curvePublic, cb);
};
messenger.getFriendStatus = function (curvePublic, cb) {
postMessage("CONTACTS_GET_FRIEND_STATUS", curvePublic, cb);
};
messenger.getMoreHistory = function (data, cb) {
postMessage("CONTACTS_GET_MORE_HISTORY", data, cb);
};
messenger.sendMessage = function (data, cb) {
postMessage("CONTACTS_SEND_MESSAGE", data, cb);
};
messenger.setChannelHead = function (data, cb) {
postMessage("CONTACTS_SET_CHANNEL_HEAD", data, cb);
};
messenger.execCommand = function (data, cb) {
postMessage("CHAT_COMMAND", data, cb);
};
messenger.onEvent = Util.mkEvent();
messenger.onMessageEvent = Util.mkEvent();
messenger.onJoinEvent = Util.mkEvent();
messenger.onLeaveEvent = Util.mkEvent();
messenger.onUpdateEvent = Util.mkEvent();
messenger.onFriendEvent = Util.mkEvent();
messenger.onUnfriendEvent = Util.mkEvent();
// Pad RPC
var pad = common.padRpc = {};
@@ -1082,13 +1047,6 @@ define([
common.onNetworkReconnect.fire(data);
});
},
// Messenger
CONTACTS_MESSAGE: common.messenger.onMessageEvent.fire,
CONTACTS_JOIN: common.messenger.onJoinEvent.fire,
CONTACTS_LEAVE: common.messenger.onLeaveEvent.fire,
CONTACTS_UPDATE: common.messenger.onUpdateEvent.fire,
CONTACTS_FRIEND: common.messenger.onFriendEvent.fire,
CONTACTS_UNFRIEND: common.messenger.onUnfriendEvent.fire,
// Chat
CHAT_EVENT: common.messenger.onEvent.fire,
// Pad

View File

@@ -898,83 +898,6 @@ define([
};
Store.messenger = {
getFriendList: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.getFriendList(function (e, keys) {
cb({
error: e,
data: keys,
});
});
},
getMyInfo: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.getMyInfo(function (e, info) {
cb({
error: e,
data: info,
});
});
},
getFriendInfo: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.getFriendInfo(data, function (e, info) {
cb({
error: e,
data: info,
});
});
},
removeFriend: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.removeFriend(data, function (e, info) {
cb({
error: e,
data: info,
});
});
},
openFriendChannel: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.openFriendChannel(data, function (e) {
cb({ error: e, });
});
},
getFriendStatus: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.getStatus(data, function (e, online) {
cb({
error: e,
data: online,
});
});
},
getMoreHistory: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.getMoreHistory(data.curvePublic, data.sig, data.count, function (e, history) {
cb({
error: e,
data: history,
});
});
},
sendMessage: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.sendMessage(data.curvePublic, data.content, function (e) {
cb({
error: e,
});
});
},
setChannelHead: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.setChannelHead(data.curvePublic, data.sig, function (e) {
cb({
error: e
});
});
},
execCommand: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.execCommand(data, cb);
@@ -1360,39 +1283,6 @@ define([
var loadMessenger = function () {
if (AppConfig.availablePadTypes.indexOf('contacts') === -1) { return; }
var messenger = store.messenger = Messenger.messenger(store);
messenger.on('message', function (message) {
sendMessengerEvent('CONTACTS_MESSAGE', message);
});
messenger.on('join', function (curvePublic, channel) {
sendMessengerEvent('CONTACTS_JOIN', {
curvePublic: curvePublic,
channel: channel,
});
});
messenger.on('leave', function (curvePublic, channel) {
sendMessengerEvent('CONTACTS_LEAVE', {
curvePublic: curvePublic,
channel: channel,
});
});
messenger.on('update', function (info, types, channel) {
sendMessengerEvent('CONTACTS_UPDATE', {
types: types,
info: info,
channel: channel
});
});
messenger.on('friend', function (curvePublic) {
sendMessengerEvent('CONTACTS_FRIEND', {
curvePublic: curvePublic,
});
});
messenger.on('unfriend', function (curvePublic, removedByMe) {
sendMessengerEvent('CONTACTS_UNFRIEND', {
curvePublic: curvePublic,
removedByMe: removedByMe
});
});
messenger.on('event', function (ev, data) {
sendMessengerEvent('CHAT_EVENT', {
ev: ev,

View File

@@ -60,16 +60,6 @@ define([
// Messaging
INVITE_FROM_USERLIST: Store.inviteFromUserlist,
ADD_DIRECT_MESSAGE_HANDLERS: Store.addDirectMessageHandlers,
// Messenger
CONTACTS_GET_FRIEND_LIST: Store.messenger.getFriendList,
CONTACTS_GET_MY_INFO: Store.messenger.getMyInfo,
CONTACTS_GET_FRIEND_INFO: Store.messenger.getFriendInfo,
CONTACTS_REMOVE_FRIEND: Store.messenger.removeFriend,
CONTACTS_OPEN_FRIEND_CHANNEL: Store.messenger.openFriendChannel,
CONTACTS_GET_FRIEND_STATUS: Store.messenger.getFriendStatus,
CONTACTS_GET_MORE_HISTORY: Store.messenger.getMoreHistory,
CONTACTS_SEND_MESSAGE: Store.messenger.sendMessage,
CONTACTS_SET_CHANNEL_HEAD: Store.messenger.setChannelHead,
// Chat
CHAT_COMMAND: Store.messenger.execCommand,
// Pad

View File

@@ -713,7 +713,7 @@ define([
Cryptpad.setLanguage(data, cb);
});
sframeChan.on('Q_CONTACTS_CLEAR_OWNED_CHANNEL', function (channel, cb) {
sframeChan.on('Q_CLEAR_OWNED_CHANNEL', function (channel, cb) {
Cryptpad.clearOwnedChannel(channel, cb);
});
sframeChan.on('Q_REMOVE_OWNED_CHANNEL', function (channel, cb) {
@@ -794,37 +794,6 @@ define([
if (cfg.messaging) {
Notifier.getPermission();
sframeChan.on('Q_CONTACTS_GET_FRIEND_LIST', function (data, cb) {
Cryptpad.messenger.getFriendList(cb);
});
sframeChan.on('Q_CONTACTS_GET_MY_INFO', function (data, cb) {
Cryptpad.messenger.getMyInfo(cb);
});
sframeChan.on('Q_CONTACTS_GET_FRIEND_INFO', function (curvePublic, cb) {
Cryptpad.messenger.getFriendInfo(curvePublic, cb);
});
sframeChan.on('Q_CONTACTS_REMOVE_FRIEND', function (curvePublic, cb) {
Cryptpad.messenger.removeFriend(curvePublic, cb);
});
sframeChan.on('Q_CONTACTS_OPEN_FRIEND_CHANNEL', function (curvePublic, cb) {
Cryptpad.messenger.openFriendChannel(curvePublic, cb);
});
sframeChan.on('Q_CONTACTS_GET_STATUS', function (curvePublic, cb) {
Cryptpad.messenger.getFriendStatus(curvePublic, cb);
});
sframeChan.on('Q_CONTACTS_GET_MORE_HISTORY', function (opt, cb) {
Cryptpad.messenger.getMoreHistory(opt, cb);
});
sframeChan.on('Q_CONTACTS_SEND_MESSAGE', function (opt, cb) {
Cryptpad.messenger.sendMessage(opt, cb);
});
sframeChan.on('Q_CONTACTS_SET_CHANNEL_HEAD', function (opt, cb) {
Cryptpad.messenger.setChannelHead(opt, cb);
});
sframeChan.on('Q_CHAT_OPENPADCHAT', function (data, cb) {
Cryptpad.messenger.execCommand({
@@ -841,25 +810,6 @@ define([
Cryptpad.messenger.onEvent.reg(function (data) {
sframeChan.event('EV_CHAT_EVENT', data);
});
Cryptpad.messenger.onMessageEvent.reg(function (data) {
sframeChan.event('EV_CONTACTS_MESSAGE', data);
});
Cryptpad.messenger.onJoinEvent.reg(function (data) {
sframeChan.event('EV_CONTACTS_JOIN', data);
});
Cryptpad.messenger.onLeaveEvent.reg(function (data) {
sframeChan.event('EV_CONTACTS_LEAVE', data);
});
Cryptpad.messenger.onUpdateEvent.reg(function (data) {
sframeChan.event('EV_CONTACTS_UPDATE', data);
});
Cryptpad.messenger.onFriendEvent.reg(function (data) {
sframeChan.event('EV_CONTACTS_FRIEND', data);
});
Cryptpad.messenger.onUnfriendEvent.reg(function (data) {
sframeChan.event('EV_CONTACTS_UNFRIEND', data);
});
}
// Chrome 68 on Mac contains a bug resulting in the page turning white after a few seconds

View File

@@ -1,121 +0,0 @@
define([], function () {
var MI = {};
MI.create = function (sFrameChan) {
var messenger = {};
var _handlers = {
message: [],
join: [],
leave: [],
update: [],
friend: [],
unfriend: []
};
messenger.on = function (key, f) {
if (!_handlers[key]) { throw new Error('invalid event'); }
_handlers[key].push(f);
};
sFrameChan.on('EV_CONTACTS_MESSAGE', function (data) {
_handlers.message.forEach(function (f) {
f(data);
});
});
sFrameChan.on('EV_CONTACTS_JOIN', function (data) {
_handlers.join.forEach(function (f) {
f(data.curvePublic, data.channel);
});
});
sFrameChan.on('EV_CONTACTS_LEAVE', function (data) {
_handlers.leave.forEach(function (f) {
f(data.curvePublic, data.channel);
});
});
sFrameChan.on('EV_CONTACTS_UPDATE', function (data) {
_handlers.update.forEach(function (f) {
f(data.info, data.types, data.channel);
});
});
sFrameChan.on('EV_CONTACTS_FRIEND', function (data) {
_handlers.friend.forEach(function (f) {
f(data.curvePublic);
});
});
sFrameChan.on('EV_CONTACTS_UNFRIEND', function (data) {
_handlers.unfriend.forEach(function (f) {
f(data.curvePublic, data.removedByMe);
});
});
/*** QUERIES ***/
messenger.getFriendList = function (cb) {
sFrameChan.query('Q_CONTACTS_GET_FRIEND_LIST', null, function (err, data) {
cb(err || data.error, data.data);
});
};
messenger.getMyInfo = function (cb) {
sFrameChan.query('Q_CONTACTS_GET_MY_INFO', null, function (err, data) {
cb(err || data.error, data.data);
});
};
messenger.getFriendInfo = function (curvePublic, cb) {
sFrameChan.query('Q_CONTACTS_GET_FRIEND_INFO', curvePublic, function (err, data) {
cb(err || data.error, data.data);
//cb({ error: err, data: data, });
});
};
messenger.removeFriend = function (curvePublic, cb) {
sFrameChan.query('Q_CONTACTS_REMOVE_FRIEND', curvePublic, function (err, data) {
cb(err || data.error, data.data);
});
};
messenger.openFriendChannel = function (curvePublic, cb) {
sFrameChan.query('Q_CONTACTS_OPEN_FRIEND_CHANNEL', curvePublic, function (err, data) {
cb(err || data.error);
});
};
messenger.getStatus = function (curvePublic, cb) {
sFrameChan.query('Q_CONTACTS_GET_STATUS', curvePublic, function (err, data) {
cb(err || data.error, data.data);
});
};
messenger.getMoreHistory = function (curvePublic, sig, count, cb) {
sFrameChan.query('Q_CONTACTS_GET_MORE_HISTORY', {
curvePublic: curvePublic,
sig: sig,
count: count
}, function (err, data) {
cb(err || data.error, data.data);
});
};
messenger.sendMessage = function (curvePublic, content, cb) {
sFrameChan.query('Q_CONTACTS_SEND_MESSAGE', {
content: content,
curvePublic: curvePublic,
}, function (err, data) {
cb(err || data.error);
});
};
messenger.setChannelHead = function (curvePublic, sig, cb) {
sFrameChan.query('Q_CONTACTS_SET_CHANNEL_HEAD', {
curvePublic: curvePublic,
sig: sig,
}, function (e, data) {
cb(e || data.error);
});
};
messenger.clearOwnedChannel = function (channel, cb) {
sFrameChan.query('Q_CONTACTS_CLEAR_OWNED_CHANNEL', channel, function (e) {
cb(e);
});
};
return messenger;
};
return MI;
});

View File

@@ -153,24 +153,6 @@ define({
// Cache is wiped after each new release
'EV_CACHE_PUT': true,
// Contacts
'EV_CONTACTS_MESSAGE': true,
'EV_CONTACTS_JOIN': true,
'EV_CONTACTS_LEAVE': true,
'EV_CONTACTS_UPDATE': true,
'EV_CONTACTS_FRIEND': true,
'EV_CONTACTS_UNFRIEND': true,
'Q_CONTACTS_GET_FRIEND_LIST': true,
'Q_CONTACTS_GET_MY_INFO': true,
'Q_CONTACTS_GET_FRIEND_INFO': true,
'Q_CONTACTS_REMOVE_FRIEND': true,
'Q_CONTACTS_OPEN_FRIEND_CHANNEL': true,
'Q_CONTACTS_GET_STATUS': true,
'Q_CONTACTS_GET_MORE_HISTORY': true,
'Q_CONTACTS_SEND_MESSAGE': true,
'Q_CONTACTS_SET_CHANNEL_HEAD': true,
'Q_CONTACTS_CLEAR_OWNED_CHANNEL': true,
// Chat
'EV_CHAT_EVENT': true,
'Q_CHAT_COMMAND': true,
@@ -228,6 +210,8 @@ define({
// Remove an owned pad from the server
'Q_REMOVE_OWNED_CHANNEL': true,
// Clear an owned pad from the server (preserve metadata)
'Q_CLEAR_OWNED_CHANNEL': true,
// Notifications about connection and disconnection from the network
'EV_NETWORK_DISCONNECT': true,

View File

@@ -6,11 +6,10 @@ define([
'/common/common-interface.js',
'/common/common-hash.js',
'/common/common-feedback.js',
'/common/sframe-messenger-inner.js',
'/contacts/messenger-ui.js',
'/customize/messages.js',
], function ($, Config, ApiConfig, UIElements, UI, Hash, Feedback,
Messenger, MessengerUI, Messages) {
MessengerUI, Messages) {
var Common;
var Bar = {
@@ -425,9 +424,7 @@ Messenger, MessengerUI, Messages) {
id: 'cp-app-contacts-container',
'class': 'cp-app-contacts-inapp'
}).prependTo(toolbar.chatContent);
var sframeChan = Common.getSframeChannel();
var messenger = Messenger.create(sframeChan);
MessengerUI.create(messenger, $container, Common, toolbar);
MessengerUI.create($container, Common, toolbar);
};
var createChat = function (toolbar, config) {
if (!config.metadataMgr) {