mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 14:00:21 +00:00
Change isOpInChannel to allow multiple different user roles
This commit is contained in:
parent
863e9b0b48
commit
c09f06fccc
2 changed files with 10 additions and 6 deletions
|
@ -101,7 +101,7 @@ $(function() {
|
|||
|
||||
const channel = target.closest(".chan");
|
||||
|
||||
if (utils.isOpInChannel(channel) && channel.data("type") === "channel") {
|
||||
if (utils.hasRoleInChannel(channel, ["op"]) && channel.data("type") === "channel") {
|
||||
output += templates.contextmenu_divider();
|
||||
output += templates.contextmenu_item({
|
||||
class: "action-kick",
|
||||
|
|
|
@ -14,13 +14,13 @@ module.exports = {
|
|||
lastMessageId,
|
||||
confirmExit,
|
||||
forceFocus,
|
||||
hasRoleInChannel,
|
||||
move,
|
||||
resetHeight,
|
||||
setNick,
|
||||
toggleNickEditor,
|
||||
toggleNotificationMarkers,
|
||||
requestIdleCallback,
|
||||
isOpInChannel,
|
||||
};
|
||||
|
||||
function findCurrentNetworkChan(name) {
|
||||
|
@ -39,13 +39,17 @@ function resetHeight(element) {
|
|||
element.style.height = element.style.minHeight;
|
||||
}
|
||||
|
||||
// Given a channel element will determine if the lounge user is Op in that channel
|
||||
function isOpInChannel(channel) {
|
||||
// Given a channel element will determine if the lounge user is one of the supplied roles.
|
||||
function hasRoleInChannel(channel, roles) {
|
||||
if (!channel || !roles) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const channelID = channel.data("id");
|
||||
const network = $("#sidebar .network").has(`.chan[data-id="${channelID}"]`);
|
||||
const ownNick = network.data("nick");
|
||||
const isOP = channel.find(`.users .user-mode.op .user[data-name="${escape(ownNick)}"]`).length;
|
||||
return isOP;
|
||||
const user = channel.find(`.users .user[data-name="${escape(ownNick)}"]`).first();
|
||||
return user.parent().is("." + roles.join(", ."));
|
||||
}
|
||||
|
||||
// Triggering click event opens the virtual keyboard on mobile
|
||||
|
|
Loading…
Reference in a new issue