Merge pull request #4060 from thelounge/xpaw/fix-323
Always use multi-prefix modes
This commit is contained in:
commit
d4bf0e365f
@ -32,7 +32,7 @@
|
|||||||
:on-hover="hoverUser"
|
:on-hover="hoverUser"
|
||||||
:active="user.original === activeUser"
|
:active="user.original === activeUser"
|
||||||
:user="user.original"
|
:user="user.original"
|
||||||
v-html="user.original.mode + user.string"
|
v-html="user.string"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@ -98,18 +98,25 @@ export default {
|
|||||||
const result = this.filteredUsers;
|
const result = this.filteredUsers;
|
||||||
|
|
||||||
for (const user of result) {
|
for (const user of result) {
|
||||||
if (!groups[user.original.mode]) {
|
const mode = user.original.modes[0] || "";
|
||||||
groups[user.original.mode] = [];
|
|
||||||
|
if (!groups[mode]) {
|
||||||
|
groups[mode] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
groups[user.original.mode].push(user);
|
// Prepend user mode to search result
|
||||||
|
user.string = mode + user.string;
|
||||||
|
|
||||||
|
groups[mode].push(user);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const user of this.channel.users) {
|
for (const user of this.channel.users) {
|
||||||
if (!groups[user.mode]) {
|
const mode = user.modes[0] || "";
|
||||||
groups[user.mode] = [user];
|
|
||||||
|
if (!groups[mode]) {
|
||||||
|
groups[mode] = [user];
|
||||||
} else {
|
} else {
|
||||||
groups[user.mode].push(user);
|
groups[mode].push(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,10 @@ export default {
|
|||||||
this.$root,
|
this.$root,
|
||||||
channel,
|
channel,
|
||||||
network,
|
network,
|
||||||
channel.users.find((u) => u.nick === data.user.nick) || {nick: data.user.nick}
|
channel.users.find((u) => u.nick === data.user.nick) || {
|
||||||
|
nick: data.user.nick,
|
||||||
|
modes: [],
|
||||||
|
}
|
||||||
);
|
);
|
||||||
this.open(data.event, items);
|
this.open(data.event, items);
|
||||||
},
|
},
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
v-on="onHover ? {mouseenter: hover} : {}"
|
v-on="onHover ? {mouseenter: hover} : {}"
|
||||||
@click.prevent="openContextMenu"
|
@click.prevent="openContextMenu"
|
||||||
@contextmenu.prevent="openContextMenu"
|
@contextmenu.prevent="openContextMenu"
|
||||||
><slot>{{ user.mode }}{{ user.nick }}</slot></span
|
><slot>{{ mode }}{{ user.nick }}</slot></span
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -22,6 +22,14 @@ export default {
|
|||||||
onHover: Function,
|
onHover: Function,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
mode() {
|
||||||
|
// Message objects have a singular mode, but user objects have modes array
|
||||||
|
if (this.user.modes) {
|
||||||
|
return this.user.modes[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.user.mode;
|
||||||
|
},
|
||||||
nickColor() {
|
nickColor() {
|
||||||
return colorClass(this.user.nick);
|
return colorClass(this.user.nick);
|
||||||
},
|
},
|
||||||
|
@ -172,6 +172,7 @@ export function generateChannelContextMenu($root, channel, network) {
|
|||||||
|
|
||||||
export function generateUserContextMenu($root, channel, network, user) {
|
export function generateUserContextMenu($root, channel, network, user) {
|
||||||
const currentChannelUser = channel.users.find((u) => u.nick === network.nick) || {};
|
const currentChannelUser = channel.users.find((u) => u.nick === network.nick) || {};
|
||||||
|
const currentChannelModes = currentChannelUser.modes || [];
|
||||||
|
|
||||||
const whois = () => {
|
const whois = () => {
|
||||||
const chan = $root.$store.getters.findChannelOnCurrentNetwork(user.nick);
|
const chan = $root.$store.getters.findChannelOnCurrentNetwork(user.nick);
|
||||||
@ -221,7 +222,7 @@ export function generateUserContextMenu($root, channel, network, user) {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
if (currentChannelUser.mode === "@") {
|
if (currentChannelModes.includes("@")) {
|
||||||
items.push({
|
items.push({
|
||||||
label: "Kick",
|
label: "Kick",
|
||||||
type: "item",
|
type: "item",
|
||||||
@ -234,7 +235,7 @@ export function generateUserContextMenu($root, channel, network, user) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (user.mode === "@") {
|
if (user.modes.includes("@")) {
|
||||||
items.push({
|
items.push({
|
||||||
label: "Revoke operator (-o)",
|
label: "Revoke operator (-o)",
|
||||||
type: "item",
|
type: "item",
|
||||||
@ -260,7 +261,7 @@ export function generateUserContextMenu($root, channel, network, user) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.mode === "+") {
|
if (user.modes.includes("+")) {
|
||||||
items.push({
|
items.push({
|
||||||
label: "Revoke voice (-v)",
|
label: "Revoke voice (-v)",
|
||||||
type: "item",
|
type: "item",
|
||||||
|
@ -8,25 +8,28 @@ function User(attr, prefixLookup) {
|
|||||||
_.defaults(this, attr, {
|
_.defaults(this, attr, {
|
||||||
modes: [],
|
modes: [],
|
||||||
away: "",
|
away: "",
|
||||||
mode: "",
|
|
||||||
nick: "",
|
nick: "",
|
||||||
lastMessage: 0,
|
lastMessage: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(this, "mode", {
|
||||||
|
get() {
|
||||||
|
return this.modes[0] || "";
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
this.setModes(this.modes, prefixLookup);
|
this.setModes(this.modes, prefixLookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
User.prototype.setModes = function (modes, prefixLookup) {
|
User.prototype.setModes = function (modes, prefixLookup) {
|
||||||
// irc-framework sets character mode, but The Lounge works with symbols
|
// irc-framework sets character mode, but The Lounge works with symbols
|
||||||
this.modes = modes.map((mode) => prefixLookup[mode]);
|
this.modes = modes.map((mode) => prefixLookup[mode]);
|
||||||
|
|
||||||
this.mode = this.modes[0] || "";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
User.prototype.toJSON = function () {
|
User.prototype.toJSON = function () {
|
||||||
return {
|
return {
|
||||||
nick: this.nick,
|
nick: this.nick,
|
||||||
mode: this.mode,
|
modes: this.modes,
|
||||||
lastMessage: this.lastMessage,
|
lastMessage: this.lastMessage,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -117,9 +117,6 @@ module.exports = function (irc, network) {
|
|||||||
return userModeSortPriority[a] - userModeSortPriority[b];
|
return userModeSortPriority[a] - userModeSortPriority[b];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove in future
|
|
||||||
user.mode = (user.modes && user.modes[0]) || "";
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!usersUpdated) {
|
if (!usersUpdated) {
|
||||||
|
Loading…
Reference in New Issue
Block a user