Mute and unmute users
parent
fb50fe09ce
commit
bbf2e3a9ae
|
@ -7,6 +7,13 @@
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
media-tag:empty {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
display: inline-block;
|
||||
border: 1px solid #BBB;
|
||||
}
|
||||
|
||||
media-tag img {
|
||||
flex: 1;
|
||||
max-height: 100% !important;
|
||||
|
|
|
@ -121,6 +121,10 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
.cp-app-contacts-muted-button {
|
||||
display: none;
|
||||
order: 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
#cp-app-contacts-container.cp-app-contacts-inapp {
|
||||
|
|
|
@ -98,6 +98,13 @@
|
|||
max-height: 90vh;
|
||||
}
|
||||
}
|
||||
media-tag:empty {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
display: inline-block;
|
||||
border: 1px solid #BBB;
|
||||
}
|
||||
|
||||
.markdown_main();
|
||||
.cp-app-code-preview-empty {
|
||||
display: none;
|
||||
|
|
|
@ -435,8 +435,6 @@
|
|||
return mediaObject;
|
||||
}
|
||||
|
||||
mediaObject.tag.innerHTML = '<img style="width: 100px; height: 100px;">';
|
||||
|
||||
// Download the encrypted blob
|
||||
download(src, function (err, u8Encrypted) {
|
||||
if (err) {
|
||||
|
|
|
@ -3,9 +3,10 @@ define([
|
|||
'/customize/messages.js',
|
||||
'/common/common-util.js',
|
||||
'/common/common-interface.js',
|
||||
'/common/common-ui-elements.js',
|
||||
'/common/hyperscript.js',
|
||||
'/common/diffMarked.js',
|
||||
], function ($, Messages, Util, UI, h, DiffMd) {
|
||||
], function ($, Messages, Util, UI, UIElements, h, DiffMd) {
|
||||
'use strict';
|
||||
|
||||
var debug = console.log;
|
||||
|
@ -67,8 +68,9 @@ define([
|
|||
h('div.cp-app-contacts-category-content')
|
||||
]),
|
||||
h('div.cp-app-contacts-friends.cp-app-contacts-category', [
|
||||
h('div.cp-app-contacts-category-content'),
|
||||
h('div.cp-app-contacts-category-content.cp-contacts-friends'),
|
||||
h('h2.cp-app-contacts-category-title', Messages.contacts_friends),
|
||||
h('button.cp-app-contacts-muted-button', Messages.contacts_manageMuted || 'MANAGE MUTED') // XXX
|
||||
]),
|
||||
h('div.cp-app-contacts-rooms.cp-app-contacts-category', [
|
||||
h('div.cp-app-contacts-category-content'),
|
||||
|
@ -486,6 +488,15 @@ define([
|
|||
}
|
||||
};
|
||||
|
||||
var muteUser = function (data) {
|
||||
execCommand('MUTE_USER', {
|
||||
curvePublic: data.curvePublic,
|
||||
name: data.displayName || data.name,
|
||||
avatar: data.avatar
|
||||
}, function (e /*, removed */) {
|
||||
if (e) { return void console.error(e); }
|
||||
});
|
||||
};
|
||||
var removeFriend = function (curvePublic) {
|
||||
execCommand('REMOVE_FRIEND', curvePublic, function (e /*, removed */) {
|
||||
if (e) { return void console.error(e); }
|
||||
|
@ -529,13 +540,16 @@ define([
|
|||
if (!channel.isFriendChat) { return; }
|
||||
var curvePublic = channel.curvePublic;
|
||||
var friend = contactsData[curvePublic] || friendData;
|
||||
UI.confirm(Messages._getKey('contacts_confirmRemove', [
|
||||
Util.fixHTML(friend.name)
|
||||
]), function (yes) {
|
||||
var muteBox = UI.createCheckbox('cp-contacts-mute', Messages.contacts_mute, false);
|
||||
var content = h('div', [
|
||||
h('p', Messages._getKey('contacts_confirmRemove', [Util.fixHTML(friend.name)])),
|
||||
muteBox
|
||||
]);
|
||||
UI.confirm(content, function (yes) {
|
||||
if (!yes) { return; }
|
||||
removeFriend(curvePublic, function (e) {
|
||||
if (e) { return void console.error(e); }
|
||||
});
|
||||
var mute = Util.isChecked($(content).find('#cp-contacts-mute'));
|
||||
muteUser(friend);
|
||||
removeFriend(curvePublic);
|
||||
// TODO remove friend from userlist ui
|
||||
// FIXME seems to trigger EJOINED from netflux-websocket (from server);
|
||||
// (tried to join a channel in which you were already present)
|
||||
|
@ -806,6 +820,40 @@ 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();
|
||||
});
|
||||
|
||||
$container.removeClass('cp-app-contacts-initializing');
|
||||
};
|
||||
|
||||
|
|
|
@ -458,6 +458,29 @@ define([
|
|||
}
|
||||
};
|
||||
|
||||
var muteUser = function (ctx, data, _cb) {
|
||||
var cb = Util.once(Util.mkAsync(_cb));
|
||||
var proxy = ctx.store.proxy;
|
||||
var muted = proxy.mutedUsers = proxy.mutedUsers || {};
|
||||
if (muted[data.curvePublic]) { return void cb(); }
|
||||
muted[data.curvePublic] = data;
|
||||
cb();
|
||||
};
|
||||
var unmuteUser = function (ctx, curvePublic, _cb) {
|
||||
var cb = Util.once(Util.mkAsync(_cb));
|
||||
var proxy = ctx.store.proxy;
|
||||
var muted = proxy.mutedUsers = proxy.mutedUsers || {};
|
||||
delete muted[curvePublic];
|
||||
cb();
|
||||
};
|
||||
var getMutedUsers = function (ctx, cb) {
|
||||
var proxy = ctx.store.proxy;
|
||||
if (cb) {
|
||||
return void cb(proxy.mutedUsers || {});
|
||||
}
|
||||
return proxy.mutedUsers || {};
|
||||
};
|
||||
|
||||
var openChannel = function (ctx, data) {
|
||||
var proxy = ctx.store.proxy;
|
||||
var network = ctx.store.network;
|
||||
|
@ -990,6 +1013,9 @@ define([
|
|||
if (cmd === 'GET_ROOMS') {
|
||||
return void getRooms(ctx, data, cb);
|
||||
}
|
||||
if (cmd === 'GET_MUTED_USERS') {
|
||||
return void getMutedUsers(ctx, cb);
|
||||
}
|
||||
if (cmd === 'GET_USERLIST') {
|
||||
return void getUserList(ctx, data, cb);
|
||||
}
|
||||
|
@ -1002,6 +1028,12 @@ define([
|
|||
if (cmd === 'REMOVE_FRIEND') {
|
||||
return void removeFriend(ctx, data, cb);
|
||||
}
|
||||
if (cmd === 'MUTE_USER') {
|
||||
return void muteUser(ctx, data, cb);
|
||||
}
|
||||
if (cmd === 'UNMUTE_USER') {
|
||||
return void unmuteUser(ctx, data, cb);
|
||||
}
|
||||
if (cmd === 'GET_STATUS') {
|
||||
return void getStatus(ctx, data, cb);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue