Skip to content

Commit

Permalink
invalidate own data if user himself was kicked from the group
Browse files Browse the repository at this point in the history
  • Loading branch information
Aero56 committed Jan 30, 2024
1 parent ac98636 commit a91a8e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/GroupPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const GroupPlayer = ({ group, player, isHost }: GroupPlayerProps) => {
if (status === 'SUBSCRIBED') {
channel.send({
type: 'broadcast',
event: 'update',
event: 'kick',
payload: {
message: `${player.username} was kicked from the group!`,
player,
},
});
}
Expand Down
11 changes: 11 additions & 0 deletions src/pages/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ const Group = () => {
queryClient.invalidateQueries(['group', id]);
toast(payload.message);
})
.on('broadcast', { event: 'kick' }, ({ payload }) => {
if (user && payload.player.id === user.id) {
toast('You were kicked from the group!');
queryClient.invalidateQueries(['group', id]);
queryClient.invalidateQueries(['player', user.id]);
return;
}

toast(`${payload.player.username} was kicked from the group!`);
queryClient.invalidateQueries(['group', id]);
})
.on(
'postgres_changes',
{
Expand Down

0 comments on commit a91a8e2

Please sign in to comment.