From 46aade557d5a7d997425a6c6993d62729c2af8dc Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Thu, 30 Dec 2021 18:19:22 -0600 Subject: [PATCH] COR-192 Don't set status if it's the same --- .../elements/contexts/context-menu-connection-info.tsx | 6 ++++-- src/server/server-controller.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client/webapp/elements/contexts/context-menu-connection-info.tsx b/src/client/webapp/elements/contexts/context-menu-connection-info.tsx index 12e4af9..839c41f 100644 --- a/src/client/webapp/elements/contexts/context-menu-connection-info.tsx +++ b/src/client/webapp/elements/contexts/context-menu-connection-info.tsx @@ -16,8 +16,10 @@ const ConnectionInfoContextMenu: FC = (props: Co const { guild, selfMember, relativeToRef, close, setOverlay } = props; const setSelfStatus = useCallback(async (status: string) => { - await guild.requestSetStatus(status); - }, [ guild ]); + if (selfMember.status !== status) { + await guild.requestSetStatus(status); + } + }, [ guild, selfMember ]); const statusElements = useMemo(() => { return [ 'online', 'away', 'busy', 'invisible' ].map(status => { diff --git a/src/server/server-controller.ts b/src/server/server-controller.ts index 3e26d96..330d341 100644 --- a/src/server/server-controller.ts +++ b/src/server/server-controller.ts @@ -634,12 +634,16 @@ function bindActionEvents(io: socketio.Server, client: socketio.Socket, identity LOG.info(`u#${identity.memberId}: setting status to ${status}`); + const before = await DB.getMember(identity.guildId, identity.memberId); await DB.setMemberStatus(identity.guildId, identity.memberId, status); const updated = await DB.getMember(identity.guildId, identity.memberId); respond(null, updated); - - io.to(identity.guildId).emit('update-member', updated); + + if (before.status !== updated.status) { + // Only send the update event if it actually changed + io.to(identity.guildId).emit('update-member', updated); + } } );