COR-192 Don't set status if it's the same

This commit is contained in:
Michael Peters 2021-12-30 18:19:22 -06:00
parent 80bb3b0581
commit 46aade557d
2 changed files with 10 additions and 4 deletions

View File

@ -16,8 +16,10 @@ const ConnectionInfoContextMenu: FC<ConnectionInfoContextMenuProps> = (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 => {

View File

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