mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-10 01:03:36 -05:00
Add nicknames + role colours back.
This commit is contained in:
parent
cc444adef8
commit
9bb9d1fa1e
1 changed files with 19 additions and 11 deletions
|
@ -1,8 +1,11 @@
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
import { User } from "revolt.js/dist/maps/Users";
|
import { User } from "revolt.js/dist/maps/Users";
|
||||||
|
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
|
|
||||||
|
import { useClient } from "../../../context/revoltjs/RevoltClient";
|
||||||
|
|
||||||
import UserIcon from "./UserIcon";
|
import UserIcon from "./UserIcon";
|
||||||
|
|
||||||
export const Username = observer(
|
export const Username = observer(
|
||||||
|
@ -13,30 +16,35 @@ export const Username = observer(
|
||||||
let username = user?.username;
|
let username = user?.username;
|
||||||
let color;
|
let color;
|
||||||
|
|
||||||
/* // ! FIXME: this must be really bad for perf.
|
|
||||||
if (user) {
|
if (user) {
|
||||||
let { server } = useParams<{ server?: string }>();
|
const { server } = useParams<{ server?: string }>();
|
||||||
if (server) {
|
if (server) {
|
||||||
let ctx = useForceUpdate();
|
const client = useClient();
|
||||||
let member = useMember(`${server}${user._id}`, ctx);
|
const member = client.members.getKey({
|
||||||
|
server,
|
||||||
|
user: user._id,
|
||||||
|
});
|
||||||
|
|
||||||
if (member) {
|
if (member) {
|
||||||
if (member.nickname) {
|
if (member.nickname) {
|
||||||
username = member.nickname;
|
username = member.nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (member.roles && member.roles.length > 0) {
|
if (member.roles && member.roles.length > 0) {
|
||||||
let s = useServer(server, ctx);
|
let srv = client.servers.get(member._id.server);
|
||||||
for (let role of member.roles) {
|
if (srv?.roles) {
|
||||||
let c = s?.roles?.[role].colour;
|
for (let role of member.roles) {
|
||||||
if (c) {
|
let c = srv.roles[role].colour;
|
||||||
color = c;
|
if (c) {
|
||||||
continue;
|
color = c;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} */
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span {...otherProps} style={{ color }}>
|
<span {...otherProps} style={{ color }}>
|
||||||
|
|
Loading…
Reference in a new issue