1
0
mirror of https://github.com/spacebarchat/client.git synced 2024-11-21 18:02:32 +01:00

guild member update event

This commit is contained in:
Puyodead1 2024-01-06 11:21:12 -05:00
parent 64f8c42de7
commit 3c098ea441
No known key found for this signature in database
GPG Key ID: BA5F91AAEF68E5CE
5 changed files with 17 additions and 3 deletions

View File

@ -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"

View File

@ -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);

View File

@ -193,7 +193,7 @@ function UserProfilePopout({ user, member }: Props) {
<Section>
<div>
<UsernameWrapper>
<NicknameText>{user.username}</NicknameText>
<NicknameText>{member?.nick ?? user.username}</NicknameText>
<div>
<UsernameText>
{user.username}#{user.discriminator}

View File

@ -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 &&

View File

@ -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;