feat(voiceChannelLog): display username on profile picture hover

This commit is contained in:
verticalsync 2024-10-21 20:18:22 +03:00
parent 40ba524206
commit 5585d4cd94
No known key found for this signature in database
GPG key ID: C2BC9F32343245E1
4 changed files with 18 additions and 7 deletions

View file

@ -32,7 +32,8 @@
text-align: center;
margin-top: 10px;
padding-left: 10px;
padding-right: 10px
padding-right: 10px;
cursor: pointer;
}
.vc-voice-channel-log-icon {

View file

@ -7,7 +7,7 @@
import "./VoiceChannelLogEntryComponent.css";
import { classes } from "@utils/misc";
import { React, Timestamp, UserStore } from "@webpack/common";
import { React, Timestamp, Tooltip, UserStore } from "@webpack/common";
import { Channel } from "discord-types/general";
import { Util } from "Vencord";
@ -20,11 +20,16 @@ export function VoiceChannelLogEntryComponent({ logEntry, channel }: { logEntry:
return <li className="vc-voice-channel-log">
<Timestamp className={cl("timestamp")} timestamp={new Date(logEntry.timestamp)} compact isInline={false} cozyAlt></Timestamp>
<Icon logEntry={logEntry} channel={channel} className={cl("icon")} />
<img
className={classes(cl("avatar"))}
onClick={() => Util.openUserProfile(logEntry.userId)}
src={user.getAvatarURL(channel.getGuildId())}
/>
<Tooltip text={logEntry.username}>
{(tooltipProps: any) => (
<img
{...tooltipProps}
className={classes(cl("avatar"))}
onClick={() => Util.openUserProfile(logEntry.userId)}
src={user.getAvatarURL(channel.getGuildId())}
/>
)}
</Tooltip>
<div className={cl("content")}>
{ }
</div>

View file

@ -119,7 +119,10 @@ export default definePlugin({
const clientUserId = UserStore.getCurrentUser().id;
voiceStates.forEach(state => {
// mmmm hacky workaround
console.log(state);
const { userId, channelId } = state;
const user = UserStore.getUser(userId) as User & { globalName: string; };
const username = user.globalName || user.username;
let { oldChannelId } = state;
if (userId === clientUserId && channelId !== clientOldChannelId) {
oldChannelId = clientOldChannelId;
@ -131,6 +134,7 @@ export default definePlugin({
const logEntry = {
userId,
username,
oldChannel: oldChannelId || null,
newChannel: channelId || null,
timestamp: new Date()

View file

@ -6,6 +6,7 @@
export interface VoiceChannelLogEntry {
userId: string;
username: string;
oldChannel: string | null;
newChannel: string | null;
timestamp: Date;