Disable friends chat in pad messenger
This commit is contained in:
parent
1895d6cbd8
commit
6c27d2964c
@ -125,6 +125,8 @@
|
|||||||
}
|
}
|
||||||
#cp-app-contacts-container.cp-app-contacts-inapp {
|
#cp-app-contacts-container.cp-app-contacts-inapp {
|
||||||
#cp-app-contacts-friendlist {
|
#cp-app-contacts-friendlist {
|
||||||
|
display: none;
|
||||||
|
/*
|
||||||
transition: width 0.2s ease-in-out 0.2s;
|
transition: width 0.2s ease-in-out 0.2s;
|
||||||
width: 68px;
|
width: 68px;
|
||||||
.cp-app-contacts-friend {
|
.cp-app-contacts-friend {
|
||||||
@ -145,6 +147,7 @@
|
|||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -262,6 +262,14 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
button {
|
||||||
|
width: 20px;
|
||||||
|
font-size: 16px;
|
||||||
|
padding: 0;
|
||||||
|
border: none;
|
||||||
|
height: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.cp-toolbar-userlist-name-input {
|
.cp-toolbar-userlist-name-input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@ -278,14 +286,6 @@
|
|||||||
min-height: 0;
|
min-height: 0;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
.cp-toolbar-userlist-name-edit {
|
|
||||||
width: 20px;
|
|
||||||
font-size: 16px;
|
|
||||||
padding: 0;
|
|
||||||
border: none;
|
|
||||||
height: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.cp-toolbar-userlist-friend {
|
.cp-toolbar-userlist-friend {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
@ -387,7 +387,7 @@
|
|||||||
color: @toolbar-color;
|
color: @toolbar-color;
|
||||||
color: var(--toolbar-color);
|
color: var(--toolbar-color);
|
||||||
}
|
}
|
||||||
.cp-toolbar-userlist-name-edit {
|
.cp-toolbar-userlist-button {
|
||||||
color: @toolbar-userlist-name-edit;
|
color: @toolbar-userlist-name-edit;
|
||||||
color: var(--toolbar-userlist-name-edit);
|
color: var(--toolbar-userlist-name-edit);
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|||||||
@ -204,7 +204,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Make sure the data we have about our friends are up-to-date when we see them online
|
// Make sure the data we have about our friends are up-to-date when we see them online
|
||||||
var checkFriendData = function (curve, data) {
|
var checkFriendData = function (curve, data, channel) {
|
||||||
if (curve === proxy.curvePublic) { return; }
|
if (curve === proxy.curvePublic) { return; }
|
||||||
var friend = getFriend(proxy, curve);
|
var friend = getFriend(proxy, curve);
|
||||||
if (!friend) { return; }
|
if (!friend) { return; }
|
||||||
@ -217,7 +217,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
eachHandler('update', function (f) {
|
eachHandler('update', function (f) {
|
||||||
f(clone(data), types);
|
f(clone(data), types, channel);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ define([
|
|||||||
// the sender field. This is to prevent replay attacks.
|
// the sender field. This is to prevent replay attacks.
|
||||||
if (parsed[2] !== sender || !parsed[1]) { return; }
|
if (parsed[2] !== sender || !parsed[1]) { return; }
|
||||||
channel.mapId[sender] = parsed[1];
|
channel.mapId[sender] = parsed[1];
|
||||||
checkFriendData(parsed[1].curvePublic, parsed[1]);
|
checkFriendData(parsed[1].curvePublic, parsed[1], channel.id);
|
||||||
eachHandler('join', function (f) {
|
eachHandler('join', function (f) {
|
||||||
f(parsed[1], channel.id);
|
f(parsed[1], channel.id);
|
||||||
});
|
});
|
||||||
@ -328,7 +328,7 @@ define([
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (parsedMsg[0] === Types.update) {
|
if (parsedMsg[0] === Types.update) {
|
||||||
checkFriendData(parsedMsg[1], parsedMsg[3]);
|
checkFriendData(parsedMsg[1], parsedMsg[3], channel.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parsedMsg[0] === Types.unfriend) {
|
if (parsedMsg[0] === Types.unfriend) {
|
||||||
@ -809,7 +809,10 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var ready = false;
|
var ready = false;
|
||||||
|
var initialized = false;
|
||||||
var init = function () {
|
var init = function () {
|
||||||
|
if (initialized) { return; }
|
||||||
|
initialized = true;
|
||||||
var friends = getFriendList(proxy);
|
var friends = getFriendList(proxy);
|
||||||
|
|
||||||
nThen(function (waitFor) {
|
nThen(function (waitFor) {
|
||||||
@ -827,7 +830,7 @@ define([
|
|||||||
emit('READY');
|
emit('READY');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
init();
|
//init();
|
||||||
|
|
||||||
var getRooms = function (data, cb) {
|
var getRooms = function (data, cb) {
|
||||||
if (data && data.curvePublic) {
|
if (data && data.curvePublic) {
|
||||||
@ -931,6 +934,10 @@ define([
|
|||||||
messenger.execCommand = function (obj, cb) {
|
messenger.execCommand = function (obj, cb) {
|
||||||
var cmd = obj.cmd;
|
var cmd = obj.cmd;
|
||||||
var data = obj.data;
|
var data = obj.data;
|
||||||
|
if (cmd === 'INIT_FRIENDS') {
|
||||||
|
init();
|
||||||
|
return void cb();
|
||||||
|
}
|
||||||
if (cmd === 'IS_READY') {
|
if (cmd === 'IS_READY') {
|
||||||
return void cb(ready);
|
return void cb(ready);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1366,10 +1366,11 @@ define([
|
|||||||
channel: channel,
|
channel: channel,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
messenger.on('update', function (info, types) {
|
messenger.on('update', function (info, types, channel) {
|
||||||
sendMessengerEvent('CONTACTS_UPDATE', {
|
sendMessengerEvent('CONTACTS_UPDATE', {
|
||||||
types: types,
|
types: types,
|
||||||
info: info,
|
info: info,
|
||||||
|
channel: channel
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
messenger.on('friend', function (curvePublic) {
|
messenger.on('friend', function (curvePublic) {
|
||||||
|
|||||||
@ -35,7 +35,7 @@ define([], function () {
|
|||||||
});
|
});
|
||||||
sFrameChan.on('EV_CONTACTS_UPDATE', function (data) {
|
sFrameChan.on('EV_CONTACTS_UPDATE', function (data) {
|
||||||
_handlers.update.forEach(function (f) {
|
_handlers.update.forEach(function (f) {
|
||||||
f(data.info, data.types);
|
f(data.info, data.types, data.channel);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
sFrameChan.on('EV_CONTACTS_FRIEND', function (data) {
|
sFrameChan.on('EV_CONTACTS_FRIEND', function (data) {
|
||||||
|
|||||||
@ -234,16 +234,15 @@ Messenger, MessengerUI, Messages) {
|
|||||||
var name = data.name || Messages.anonymous;
|
var name = data.name || Messages.anonymous;
|
||||||
var $span = $('<span>', {'class': 'cp-avatar'});
|
var $span = $('<span>', {'class': 'cp-avatar'});
|
||||||
var $rightCol = $('<span>', {'class': 'cp-toolbar-userlist-rightcol'});
|
var $rightCol = $('<span>', {'class': 'cp-toolbar-userlist-rightcol'});
|
||||||
var $nameSpan = $('<span>', {'class': 'cp-toolbar-userlist-name'}).text(name).appendTo($rightCol);
|
var $nameSpan = $('<span>', {'class': 'cp-toolbar-userlist-name'}).appendTo($rightCol);
|
||||||
|
var $nameValue = $('<span>', {
|
||||||
|
'class': 'cp-toolbar-userlist-name-value'
|
||||||
|
}).text(name).appendTo($nameSpan);
|
||||||
var isMe = data.uid === user.uid;
|
var isMe = data.uid === user.uid;
|
||||||
if (isMe && !priv.readOnly) {
|
if (isMe && !priv.readOnly) {
|
||||||
$nameSpan.html('');
|
|
||||||
var $nameValue = $('<span>', {
|
|
||||||
'class': 'cp-toolbar-userlist-name-value'
|
|
||||||
}).text(name).appendTo($nameSpan);
|
|
||||||
if (!Config.disableProfile) {
|
if (!Config.disableProfile) {
|
||||||
var $button = $('<button>', {
|
var $button = $('<button>', {
|
||||||
'class': 'fa fa-pencil cp-toolbar-userlist-name-edit',
|
'class': 'fa fa-pencil cp-toolbar-userlist-button',
|
||||||
title: Messages.user_rename
|
title: Messages.user_rename
|
||||||
}).appendTo($nameSpan);
|
}).appendTo($nameSpan);
|
||||||
$button.hover(function (e) { e.preventDefault(); e.stopPropagation(); });
|
$button.hover(function (e) { e.preventDefault(); e.stopPropagation(); });
|
||||||
@ -299,16 +298,24 @@ Messenger, MessengerUI, Messages) {
|
|||||||
$('<span>', {'class': 'cp-toolbar-userlist-friend'}).text(Messages.userlist_pending)
|
$('<span>', {'class': 'cp-toolbar-userlist-friend'}).text(Messages.userlist_pending)
|
||||||
.appendTo($rightCol);
|
.appendTo($rightCol);
|
||||||
} else {
|
} else {
|
||||||
$('<span>', {
|
$('<button>', {
|
||||||
'class': 'fa fa-user-plus cp-toolbar-userlist-friend',
|
'class': 'fa fa-user-plus cp-toolbar-userlist-button',
|
||||||
'title': Messages._getKey('userlist_addAsFriendTitle', [
|
'title': Messages._getKey('userlist_addAsFriendTitle', [
|
||||||
name
|
name
|
||||||
])
|
])
|
||||||
}).appendTo($rightCol).click(function (e) {
|
}).appendTo($nameSpan).click(function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
Common.sendFriendRequest(data.netfluxId);
|
Common.sendFriendRequest(data.netfluxId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else if (Common.isLoggedIn() && data.curvePublic && friends[data.curvePublic]) {
|
||||||
|
$('<button>', {
|
||||||
|
'class': 'fa fa-comments-o cp-toolbar-userlist-button',
|
||||||
|
'title': Messages.userlist_chat
|
||||||
|
}).appendTo($nameSpan).click(function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
Common.openURL('/contacts/');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (data.profile) {
|
if (data.profile) {
|
||||||
$span.addClass('cp-userlist-clickable');
|
$span.addClass('cp-userlist-clickable');
|
||||||
|
|||||||
@ -45,6 +45,8 @@ define([
|
|||||||
var metadataMgr = common.getMetadataMgr();
|
var metadataMgr = common.getMetadataMgr();
|
||||||
var origin = metadataMgr.getPrivateData().origin;
|
var origin = metadataMgr.getPrivateData().origin;
|
||||||
|
|
||||||
|
var isApp = typeof(toolbar) !== "undefined";
|
||||||
|
|
||||||
$container.addClass('cp-app-contacts-initializing');
|
$container.addClass('cp-app-contacts-initializing');
|
||||||
|
|
||||||
var messaging = h('div#cp-app-contacts-messaging', [
|
var messaging = h('div#cp-app-contacts-messaging', [
|
||||||
@ -52,7 +54,7 @@ define([
|
|||||||
h('div.cp-app-contacts-info', [
|
h('div.cp-app-contacts-info', [
|
||||||
h('h2', Messages.contacts_info1_new),
|
h('h2', Messages.contacts_info1_new),
|
||||||
h('ul', [
|
h('ul', [
|
||||||
toolbar ? h('li', [
|
isApp ? h('li', [
|
||||||
Messages.contacts_info2_new,
|
Messages.contacts_info2_new,
|
||||||
h('ul', [
|
h('ul', [
|
||||||
h('li', Messages.contacts_info2a_new)
|
h('li', Messages.contacts_info2a_new)
|
||||||
@ -124,7 +126,7 @@ define([
|
|||||||
|
|
||||||
var onResize = function () {
|
var onResize = function () {
|
||||||
// Don't update the width if we are in the contacts app
|
// Don't update the width if we are in the contacts app
|
||||||
if (!toolbar) { return; }
|
if (!isApp) { return; }
|
||||||
var w = $userlist[0].offsetWidth - $userlist[0].clientWidth;
|
var w = $userlist[0].offsetWidth - $userlist[0].clientWidth;
|
||||||
$userlist.css('width', (68 + w)+'px');
|
$userlist.css('width', (68 + w)+'px');
|
||||||
};
|
};
|
||||||
@ -401,6 +403,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var updateStatus = function (id) {
|
var updateStatus = function (id) {
|
||||||
|
if (!state.channels[id]) { return; }
|
||||||
var $status = find.inList(id).find('.cp-app-contacts-status');
|
var $status = find.inList(id).find('.cp-app-contacts-status');
|
||||||
messenger.getStatus(id, function (e, online) {
|
messenger.getStatus(id, function (e, online) {
|
||||||
// if error maybe you shouldn't display this friend...
|
// if error maybe you shouldn't display this friend...
|
||||||
@ -525,6 +528,8 @@ define([
|
|||||||
|
|
||||||
messenger.on('message', function (message) {
|
messenger.on('message', function (message) {
|
||||||
var chanId = message.channel;
|
var chanId = message.channel;
|
||||||
|
var channel = state.channels[chanId];
|
||||||
|
if (!channel) { return; }
|
||||||
|
|
||||||
var chat = getChat(chanId);
|
var chat = getChat(chanId);
|
||||||
|
|
||||||
@ -532,12 +537,6 @@ define([
|
|||||||
|
|
||||||
var el_message = markup.message(message);
|
var el_message = markup.message(message);
|
||||||
|
|
||||||
var channel = state.channels[chanId];
|
|
||||||
if (!channel) {
|
|
||||||
console.log(message);
|
|
||||||
console.error('expected channel [%s] to be open', chanId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
common.notify();
|
common.notify();
|
||||||
|
|
||||||
channel.messages.push(message);
|
channel.messages.push(message);
|
||||||
@ -588,8 +587,11 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
// change in your friend list
|
// change in your friend list
|
||||||
messenger.on('update', function (info, types) {
|
messenger.on('update', function (info, types, channel) {
|
||||||
if (!info || !info.curvePublic) { return; }
|
if (!info || !info.curvePublic) { return; }
|
||||||
|
// Make sure we don't store useless data (friends data in pad chat or the other way)
|
||||||
|
if (channel && !state.channels[channel]) { return; }
|
||||||
|
|
||||||
var curvePublic = info.curvePublic;
|
var curvePublic = info.curvePublic;
|
||||||
contactsData[curvePublic] = info;
|
contactsData[curvePublic] = info;
|
||||||
|
|
||||||
@ -636,7 +638,7 @@ define([
|
|||||||
|
|
||||||
var execCommand = function (cmd, data, cb) {
|
var execCommand = function (cmd, data, cb) {
|
||||||
sframeChan.query('Q_CHAT_COMMAND', {cmd: cmd, data: data}, function (err, obj) {
|
sframeChan.query('Q_CHAT_COMMAND', {cmd: cmd, data: data}, function (err, obj) {
|
||||||
if (err || obj.error) { return void cb(err || obj.error); }
|
if (err || (obj && obj.error)) { return void cb(err || (obj && obj.error)); }
|
||||||
cb(void 0, obj);
|
cb(void 0, obj);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -686,10 +688,16 @@ define([
|
|||||||
reorderRooms();
|
reorderRooms();
|
||||||
|
|
||||||
updateStatus(id);
|
updateStatus(id);
|
||||||
|
|
||||||
|
if (isApp && room.isPadChat) {
|
||||||
|
$container.removeClass('cp-app-contacts-initializing');
|
||||||
|
display(room.id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
messenger.on('friend', function (curvePublic) {
|
messenger.on('friend', function (curvePublic) {
|
||||||
|
if (isApp) { return; }
|
||||||
debug('new friend: ', curvePublic);
|
debug('new friend: ', curvePublic);
|
||||||
execCommand('GET_ROOMS', {curvePublic: curvePublic}, function (err, rooms) {
|
execCommand('GET_ROOMS', {curvePublic: curvePublic}, function (err, rooms) {
|
||||||
if (err) { return void console.error(err); }
|
if (err) { return void console.error(err); }
|
||||||
@ -699,6 +707,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
messenger.on('unfriend', function (curvePublic, removedByMe) {
|
messenger.on('unfriend', function (curvePublic, removedByMe) {
|
||||||
|
if (isApp) { return; }
|
||||||
var channel = state.channels[state.active];
|
var channel = state.channels[state.active];
|
||||||
$userlist.find(userQuery(curvePublic)).remove();
|
$userlist.find(userQuery(curvePublic)).remove();
|
||||||
$messages.find(userQuery(curvePublic)).remove();
|
$messages.find(userQuery(curvePublic)).remove();
|
||||||
@ -741,6 +750,7 @@ define([
|
|||||||
|
|
||||||
var ready = false;
|
var ready = false;
|
||||||
var onMessengerReady = function () {
|
var onMessengerReady = function () {
|
||||||
|
if (isApp) { return; }
|
||||||
if (ready) { return; }
|
if (ready) { return; }
|
||||||
ready = true;
|
ready = true;
|
||||||
|
|
||||||
@ -769,8 +779,6 @@ define([
|
|||||||
room.name = name;
|
room.name = name;
|
||||||
rooms.forEach(initializeRoom);
|
rooms.forEach(initializeRoom);
|
||||||
});
|
});
|
||||||
|
|
||||||
$container.removeClass('cp-app-contacts-initializing');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var onDisconnect = function () {
|
var onDisconnect = function () {
|
||||||
@ -784,9 +792,12 @@ define([
|
|||||||
|
|
||||||
// Initialize chat when outer is ready (all channels loaded)
|
// Initialize chat when outer is ready (all channels loaded)
|
||||||
// TODO: try again in outer if fail to load a channel
|
// TODO: try again in outer if fail to load a channel
|
||||||
execCommand('IS_READY', null, function (err, yes) {
|
if (!isApp) {
|
||||||
if (yes) { onMessengerReady(); }
|
execCommand('INIT_FRIENDS', null, function () {});
|
||||||
});
|
execCommand('IS_READY', null, function (err, yes) {
|
||||||
|
if (yes) { onMessengerReady(); }
|
||||||
|
});
|
||||||
|
}
|
||||||
sframeChan.on('EV_CHAT_EVENT', function (obj) {
|
sframeChan.on('EV_CHAT_EVENT', function (obj) {
|
||||||
if (obj.ev === 'READY') {
|
if (obj.ev === 'READY') {
|
||||||
onMessengerReady();
|
onMessengerReady();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user