1
0
mirror of https://github.com/spacebarchat/client.git synced 2024-11-25 03:32:54 +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", "homepage": "https://spacebar.chat",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"name": "spacebar-client", "name": "spacebar-client",
"packageManager": "pnpm@8.11.0", "packageManager": "pnpm@8.14.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/spacebarchat/client.git" "url": "git+https://github.com/spacebarchat/client.git"

View File

@ -1,4 +1,5 @@
import { PresenceUpdateStatus } from "@spacebarchat/spacebar-api-types/v9"; import { PresenceUpdateStatus } from "@spacebarchat/spacebar-api-types/v9";
import { observer } from "mobx-react-lite";
import { useContext } from "react"; import { useContext } from "react";
import styled from "styled-components"; import styled from "styled-components";
import { ContextMenuContext } from "../../contexts/ContextMenuContext"; 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> <Section>
<div> <div>
<UsernameWrapper> <UsernameWrapper>
<NicknameText>{user.username}</NicknameText> <NicknameText>{member?.nick ?? user.username}</NicknameText>
<div> <div>
<UsernameText> <UsernameText>
{user.username}#{user.discriminator} {user.username}#{user.discriminator}

View File

@ -14,6 +14,7 @@ const MentionText = styled.span<{ color?: string; withHover?: boolean }>`
padding: 0 2px; padding: 0 2px;
border-radius: 4px; border-radius: 4px;
background-color: hsl(${(props) => props.color ?? "var(--primary-hsl)"} / 0.3); background-color: hsl(${(props) => props.color ?? "var(--primary-hsl)"} / 0.3);
user-select: ${(props) => (props.withHover ? "none" : "inherit")};
${(props) => ${(props) =>
props.withHover && props.withHover &&

View File

@ -15,6 +15,7 @@ import {
GatewayGuildMemberAddDispatchData, GatewayGuildMemberAddDispatchData,
GatewayGuildMemberListUpdateDispatchData, GatewayGuildMemberListUpdateDispatchData,
GatewayGuildMemberRemoveDispatchData, GatewayGuildMemberRemoveDispatchData,
GatewayGuildMemberUpdateDispatchData,
GatewayGuildModifyDispatchData, GatewayGuildModifyDispatchData,
GatewayHeartbeat, GatewayHeartbeat,
GatewayHelloData, GatewayHelloData,
@ -135,6 +136,7 @@ export default class GatewayConnectionStore {
this.dispatchHandlers.set(GatewayDispatchEvents.GuildDelete, this.onGuildDelete); this.dispatchHandlers.set(GatewayDispatchEvents.GuildDelete, this.onGuildDelete);
this.dispatchHandlers.set(GatewayDispatchEvents.GuildMemberAdd, this.onGuildMemberAdd); this.dispatchHandlers.set(GatewayDispatchEvents.GuildMemberAdd, this.onGuildMemberAdd);
this.dispatchHandlers.set(GatewayDispatchEvents.GuildMemberRemove, this.onGuildMemberRemove); 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.GuildMemberListUpdate, this.onGuildMemberListUpdate);
this.dispatchHandlers.set(GatewayDispatchEvents.ChannelCreate, this.onChannelCreate); this.dispatchHandlers.set(GatewayDispatchEvents.ChannelCreate, this.onChannelCreate);
@ -562,6 +564,16 @@ export default class GatewayConnectionStore {
guild.members.remove(data.user.id); 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) => { private onGuildMemberListUpdate = (data: GatewayGuildMemberListUpdateDispatchData) => {
this.logger.debug("Received GuildMemberListUpdate event"); this.logger.debug("Received GuildMemberListUpdate event");
const { guild_id } = data; const { guild_id } = data;