Fix mute/unmute button in contacts

pull/1/head
yflory 5 years ago
parent 64fba3e379
commit 0b248348eb

@ -491,15 +491,8 @@ define([
}; };
var unmuteUser = function (curve) { var unmuteUser = function (curve) {
execCommand('UNMUTE_USER', curve, function (e, data) { execCommand('UNMUTE_USER', curve, function (e) {
if (e) { return void console.error(e); } if (e) { return void console.error(e); }
var $button = $('.cp-contacts-muted-user').find('button[data-user="'+curve+'"]');
$button.closest('div').remove();
if (!data) { $button.hide(); }
$('.cp-app-contacts-friend[data-user="'+curve+'"]')
.find('.cp-unmute-icon').show();
$('.cp-app-contacts-friend[data-user="'+curve+'"]')
.find('.cp-mute-icon').show();
}); });
}; };
var muteUser = function (data) { var muteUser = function (data) {
@ -567,7 +560,7 @@ define([
if (friendData.profile) { window.open(origin + '/profile/#' + friendData.profile); } if (friendData.profile) { window.open(origin + '/profile/#' + friendData.profile); }
}); });
$(unmute).click(function (e) { $(unmute).on('click dblclick', function (e) {
e.stopPropagation(); e.stopPropagation();
var channel = state.channels[id]; var channel = state.channels[id];
if (!channel.isFriendChat) { return; } if (!channel.isFriendChat) { return; }
@ -577,7 +570,7 @@ define([
unmuteUser(curvePublic); unmuteUser(curvePublic);
}); });
$(mute).click(function (e) { $(mute).on('click dblclick', function (e) {
e.stopPropagation(); e.stopPropagation();
var channel = state.channels[id]; var channel = state.channels[id];
if (!channel.isFriendChat) { return; } if (!channel.isFriendChat) { return; }
@ -863,6 +856,10 @@ define([
var $button = $userlist.find('.cp-app-contacts-muted-button'); var $button = $userlist.find('.cp-app-contacts-muted-button');
$('.cp-app-contacts-friend[data-user]')
.find('.cp-mute-icon').show();
$('.cp-app-contacts-friend[data-user]')
.find('.cp-unmute-icon').hide();
if (!muted || Object.keys(muted).length === 0) { if (!muted || Object.keys(muted).length === 0) {
$button.hide(); $button.hide();
return; return;
@ -871,6 +868,8 @@ define([
var rows = Object.keys(muted).map(function (curve) { var rows = Object.keys(muted).map(function (curve) {
$('.cp-app-contacts-friend[data-user="'+curve+'"]') $('.cp-app-contacts-friend[data-user="'+curve+'"]')
.find('.cp-mute-icon').hide(); .find('.cp-mute-icon').hide();
$('.cp-app-contacts-friend[data-user="'+curve+'"]')
.find('.cp-unmute-icon').show();
var data = muted[curve]; var data = muted[curve];
var avatar = h('span.cp-avatar'); var avatar = h('span.cp-avatar');
var button = h('button', { var button = h('button', {

Loading…
Cancel
Save