Mute friends: dismiss notifications and fix UI issues
This commit is contained in:
@@ -186,7 +186,7 @@ define([
|
||||
markup.message = function (msg) {
|
||||
if (msg.type !== 'MSG') { return; }
|
||||
var curvePublic = msg.author;
|
||||
var name = typeof msg.name !== "undefined" ?
|
||||
var name = (typeof msg.name !== "undefined" || !contactsData[msg.author]) ?
|
||||
(msg.name || Messages.anonymous) :
|
||||
contactsData[msg.author].displayName;
|
||||
var d = msg.time ? new Date(msg.time) : undefined;
|
||||
@@ -548,7 +548,7 @@ define([
|
||||
UI.confirm(content, function (yes) {
|
||||
if (!yes) { return; }
|
||||
var mute = Util.isChecked($(content).find('#cp-contacts-mute'));
|
||||
muteUser(friend);
|
||||
if (mute) { muteUser(friend); }
|
||||
removeFriend(curvePublic);
|
||||
// TODO remove friend from userlist ui
|
||||
// FIXME seems to trigger EJOINED from netflux-websocket (from server);
|
||||
@@ -806,6 +806,45 @@ define([
|
||||
// var onJoinRoom
|
||||
// var onLeaveRoom
|
||||
|
||||
var updateMutedList = function () {
|
||||
execCommand('GET_MUTED_USERS', null, function (err, muted) {
|
||||
if (err) { return void console.error(err); }
|
||||
|
||||
var $button = $userlist.find('.cp-app-contacts-muted-button');
|
||||
|
||||
if (!muted || Object.keys(muted).length === 0) {
|
||||
$button.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
var rows = Object.keys(muted).map(function (curve) {
|
||||
var data = muted[curve];
|
||||
var avatar = h('div.cp-avatar');
|
||||
var button = h('td', h('i.fa.fa-times', {title: Messages.contacts_unmute}));
|
||||
UIElements.displayAvatar(common, $(avatar), data.avatar, data.name);
|
||||
$(button).click(function () {
|
||||
execCommand('UNMUTE_USER', curve, function (e, data) {
|
||||
if (e) { return void console.error(e); }
|
||||
$(button).closest('tr').remove();
|
||||
if (!data) { $button.hide(); }
|
||||
});
|
||||
});
|
||||
return h('tr', [
|
||||
h('td', avatar),
|
||||
h('td', data.name),
|
||||
button
|
||||
]);
|
||||
});
|
||||
var content = h('div', [
|
||||
h('p', Messages.contacts_mutedUsers),
|
||||
h('table', rows)
|
||||
]);
|
||||
$button.off('click');
|
||||
$button.click(function () {
|
||||
UI.alert(content);
|
||||
}).show();
|
||||
});
|
||||
};
|
||||
|
||||
var ready = false;
|
||||
var onMessengerReady = function () {
|
||||
@@ -820,39 +859,7 @@ define([
|
||||
rooms.forEach(initializeRoom);
|
||||
});
|
||||
|
||||
execCommand('GET_MUTED_USERS', null, function (err, muted) {
|
||||
if (err) { return void console.error(err); }
|
||||
|
||||
if (!muted || Object.keys(muted).length === 0) { return; }
|
||||
|
||||
var $button = $userlist.find('.cp-app-contacts-muted-button');
|
||||
var rows = Object.keys(muted).map(function (curve) {
|
||||
var data = muted[curve];
|
||||
var avatar = h('div.cp-avatar');
|
||||
var button = h('td', h('i.fa.fa-times', {title: Messages.contacts_unmute}));
|
||||
UIElements.displayAvatar(common, $(avatar), data.avatar, data.name);
|
||||
$(button).click(function () {
|
||||
execCommand('UNMUTE_USER', {
|
||||
curvePublic: curve,
|
||||
}, function (e /*, removed */) {
|
||||
if (e) { return void console.error(e); }
|
||||
$(button).closest('tr').remove();
|
||||
});
|
||||
});
|
||||
return h('tr', [
|
||||
h('td', avatar),
|
||||
h('td', data.name),
|
||||
button
|
||||
]);
|
||||
});
|
||||
var content = h('div', [
|
||||
h('p', Messages.contacts_mutedUsers),
|
||||
h('table', rows)
|
||||
]);
|
||||
$button.click(function () {
|
||||
UI.alert(content);
|
||||
}).show();
|
||||
});
|
||||
updateMutedList();
|
||||
|
||||
$container.removeClass('cp-app-contacts-initializing');
|
||||
};
|
||||
@@ -930,6 +937,10 @@ define([
|
||||
onUpdateData(data);
|
||||
return;
|
||||
}
|
||||
if (cmd === 'UPDATE_MUTED') {
|
||||
updateMutedList();
|
||||
return;
|
||||
}
|
||||
if (cmd === 'MESSAGE') {
|
||||
onMessage(data);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user