Fix double counting users in presence channel

This commit is contained in:
Alex Bouma 2020-09-15 15:57:50 +02:00
parent 1380f0ba0a
commit 9da68ecd40
No known key found for this signature in database
GPG Key ID: AC101F160BEBEA17
1 changed files with 4 additions and 4 deletions

View File

@ -63,9 +63,9 @@ class PresenceChannel extends Channel
{
return [
'presence' => [
'ids' => $this->getUserIds(),
'ids' => $userIds = $this->getUserIds(),
'hash' => $this->getHash(),
'count' => count($this->users),
'count' => count($userIds),
],
];
}
@ -73,7 +73,7 @@ class PresenceChannel extends Channel
public function toArray(): array
{
return array_merge(parent::toArray(), [
'user_count' => count($this->users),
'user_count' => count($this->getUserIds()),
]);
}
@ -83,7 +83,7 @@ class PresenceChannel extends Channel
return (string) $channelData->user_id;
}, $this->users);
return array_values($userIds);
return array_values(array_unique($userIds));
}
/**