Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 9da68ec

Browse files
committed
Fix double counting users in presence channel
1 parent 1380f0b commit 9da68ec

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/WebSockets/Channels/PresenceChannel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ protected function getChannelData(): array
6363
{
6464
return [
6565
'presence' => [
66-
'ids' => $this->getUserIds(),
66+
'ids' => $userIds = $this->getUserIds(),
6767
'hash' => $this->getHash(),
68-
'count' => count($this->users),
68+
'count' => count($userIds),
6969
],
7070
];
7171
}
7272

7373
public function toArray(): array
7474
{
7575
return array_merge(parent::toArray(), [
76-
'user_count' => count($this->users),
76+
'user_count' => count($this->getUserIds()),
7777
]);
7878
}
7979

@@ -83,7 +83,7 @@ protected function getUserIds(): array
8383
return (string) $channelData->user_id;
8484
}, $this->users);
8585

86-
return array_values($userIds);
86+
return array_values(array_unique($userIds));
8787
}
8888

8989
/**

0 commit comments

Comments
 (0)