From 3c098ea441a5d75809c189a3d888ed78f67025b0 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Sat, 6 Jan 2024 11:21:12 -0500 Subject: [PATCH] guild member update event --- package.json | 2 +- src/components/MemberList/MemberListItem.tsx | 3 ++- src/components/floating/UserProfilePopout.tsx | 2 +- src/components/markdown/Mention.tsx | 1 + src/stores/GatewayConnectionStore.ts | 12 ++++++++++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 8806558..3c281ae 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "homepage": "https://spacebar.chat", "license": "AGPL-3.0-only", "name": "spacebar-client", - "packageManager": "pnpm@8.11.0", + "packageManager": "pnpm@8.14.0", "repository": { "type": "git", "url": "git+https://github.com/spacebarchat/client.git" diff --git a/src/components/MemberList/MemberListItem.tsx b/src/components/MemberList/MemberListItem.tsx index 78f19cb..270b1af 100644 --- a/src/components/MemberList/MemberListItem.tsx +++ b/src/components/MemberList/MemberListItem.tsx @@ -1,4 +1,5 @@ import { PresenceUpdateStatus } from "@spacebarchat/spacebar-api-types/v9"; +import { observer } from "mobx-react-lite"; import { useContext } from "react"; import styled from "styled-components"; import { ContextMenuContext } from "../../contexts/ContextMenuContext"; @@ -96,4 +97,4 @@ function MemberListItem({ item }: Props) { ); } -export default MemberListItem; +export default observer(MemberListItem); diff --git a/src/components/floating/UserProfilePopout.tsx b/src/components/floating/UserProfilePopout.tsx index bef1126..a754d11 100644 --- a/src/components/floating/UserProfilePopout.tsx +++ b/src/components/floating/UserProfilePopout.tsx @@ -193,7 +193,7 @@ function UserProfilePopout({ user, member }: Props) {
- {user.username} + {member?.nick ?? user.username}
{user.username}#{user.discriminator} diff --git a/src/components/markdown/Mention.tsx b/src/components/markdown/Mention.tsx index b8f295f..e035c24 100644 --- a/src/components/markdown/Mention.tsx +++ b/src/components/markdown/Mention.tsx @@ -14,6 +14,7 @@ const MentionText = styled.span<{ color?: string; withHover?: boolean }>` padding: 0 2px; border-radius: 4px; background-color: hsl(${(props) => props.color ?? "var(--primary-hsl)"} / 0.3); + user-select: ${(props) => (props.withHover ? "none" : "inherit")}; ${(props) => props.withHover && diff --git a/src/stores/GatewayConnectionStore.ts b/src/stores/GatewayConnectionStore.ts index 280b8c1..c5f9d87 100644 --- a/src/stores/GatewayConnectionStore.ts +++ b/src/stores/GatewayConnectionStore.ts @@ -15,6 +15,7 @@ import { GatewayGuildMemberAddDispatchData, GatewayGuildMemberListUpdateDispatchData, GatewayGuildMemberRemoveDispatchData, + GatewayGuildMemberUpdateDispatchData, GatewayGuildModifyDispatchData, GatewayHeartbeat, GatewayHelloData, @@ -135,6 +136,7 @@ export default class GatewayConnectionStore { this.dispatchHandlers.set(GatewayDispatchEvents.GuildDelete, this.onGuildDelete); this.dispatchHandlers.set(GatewayDispatchEvents.GuildMemberAdd, this.onGuildMemberAdd); this.dispatchHandlers.set(GatewayDispatchEvents.GuildMemberRemove, this.onGuildMemberRemove); + this.dispatchHandlers.set(GatewayDispatchEvents.GuildMemberUpdate, this.onGuildMemberUpdate); this.dispatchHandlers.set(GatewayDispatchEvents.GuildMemberListUpdate, this.onGuildMemberListUpdate); this.dispatchHandlers.set(GatewayDispatchEvents.ChannelCreate, this.onChannelCreate); @@ -562,6 +564,16 @@ export default class GatewayConnectionStore { guild.members.remove(data.user.id); }; + private onGuildMemberUpdate = (data: GatewayGuildMemberUpdateDispatchData) => { + this.logger.debug("Received GuildMemberUpdate event"); + const guild = this.app.guilds.get(data.guild_id); + if (!guild) { + this.logger.warn(`[GuildMemberUpdate] Guild ${data.guild_id} not found for member ${data.user.id}`); + return; + } + guild.members.update(data as APIGuildMember); + }; + private onGuildMemberListUpdate = (data: GatewayGuildMemberListUpdateDispatchData) => { this.logger.debug("Received GuildMemberListUpdate event"); const { guild_id } = data;