This commit is contained in:
snowfudge 2024-04-30 21:34:18 -04:00 committed by GitHub
commit d87dd9aae0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 20 deletions

View file

@ -62,16 +62,9 @@ import {computed, defineComponent, nextTick, PropType, ref} from "vue";
import type {UserInMessage} from "../../shared/types/msg"; import type {UserInMessage} from "../../shared/types/msg";
import type {ClientChan, ClientUser} from "../js/types"; import type {ClientChan, ClientUser} from "../js/types";
import Username from "./Username.vue"; import Username from "./Username.vue";
import constants from "../js/constants";
const modes = { const modes = constants.modeCharToName;
"~": "owner",
"&": "admin",
"!": "admin",
"@": "op",
"%": "half-op",
"+": "voice",
"": "normal",
};
export default defineComponent({ export default defineComponent({
name: "ChatUserList", name: "ChatUserList",

View file

@ -1,6 +1,7 @@
<template> <template>
<span <span
:class="['user', {[nickColor]: store.state.settings.coloredNicks}, {active: active}]" :class="['user', {[nickColor]: store.state.settings.coloredNicks}, {active: active}]"
:data-mode="mode ? modeCharToName[mode] : null"
:data-name="user.nick" :data-name="user.nick"
role="button" role="button"
v-on="onHover ? {mouseenter: hover} : {}" v-on="onHover ? {mouseenter: hover} : {}"
@ -17,6 +18,7 @@ import eventbus from "../js/eventbus";
import colorClass from "../js/helpers/colorClass"; import colorClass from "../js/helpers/colorClass";
import type {ClientChan, ClientNetwork} from "../js/types"; import type {ClientChan, ClientNetwork} from "../js/types";
import {useStore} from "../js/store"; import {useStore} from "../js/store";
import constants from "../js/constants";
type UsernameUser = Partial<UserInMessage> & { type UsernameUser = Partial<UserInMessage> & {
mode?: string; mode?: string;
@ -73,6 +75,7 @@ export default defineComponent({
const store = useStore(); const store = useStore();
return { return {
modeCharToName: constants.modeCharToName,
mode, mode,
nickColor, nickColor,
hover, hover,

View file

@ -24,10 +24,21 @@ const timeFormats = {
msg12hWithSeconds: "hh:mm:ss A", msg12hWithSeconds: "hh:mm:ss A",
}; };
const modeCharToName = {
"~": "owner",
"&": "admin",
"!": "admin",
"@": "op",
"%": "half-op",
"+": "voice",
"": "normal",
};
export default { export default {
colorCodeMap, colorCodeMap,
commands: [] as string[], commands: [] as string[],
timeFormats, timeFormats,
modeCharToName,
// Same value as media query in CSS that forces sidebars to become overlays // Same value as media query in CSS that forces sidebars to become overlays
mobileViewportPixels: 768, mobileViewportPixels: 768,
}; };

View file

@ -4,6 +4,7 @@ import type {ClientChan, ClientNetwork, ClientUser} from "../types";
import {switchToChannel} from "../router"; import {switchToChannel} from "../router";
import {TypedStore} from "../store"; import {TypedStore} from "../store";
import useCloseChannel from "../hooks/use-close-channel"; import useCloseChannel from "../hooks/use-close-channel";
import constants from "../constants";
type BaseContextMenuItem = { type BaseContextMenuItem = {
label: string; label: string;
@ -358,19 +359,11 @@ export function generateUserContextMenu(
return items; return items;
} }
// Names of the standard modes we are able to change
const modeCharToName = {
"~": "owner",
"&": "admin",
"@": "operator",
"%": "half-op",
"+": "voice",
};
// Labels for the mode changes. For example .rev({mode: "a", symbol: "&"}) => 'Revoke admin (-a)' // Labels for the mode changes. For example .rev({mode: "a", symbol: "&"}) => 'Revoke admin (-a)'
const modeTextTemplate = { const modeTextTemplate = {
revoke(m: {symbol: string; mode: string}) { revoke(m: {symbol: string; mode: string}) {
const name = modeCharToName[m.symbol]; const name = constants.modeCharToName[m.symbol];
if (typeof name !== "string") { if (typeof name !== "string") {
return ""; return "";
@ -380,7 +373,7 @@ export function generateUserContextMenu(
return res; return res;
}, },
give(m: {symbol: string; mode: string}) { give(m: {symbol: string; mode: string}) {
const name = modeCharToName[m.symbol]; const name = constants.modeCharToName[m.symbol];
if (typeof name !== "string") { if (typeof name !== "string") {
return ""; return "";