FIX: Do not send presence leave beacon if not present in any channels

This commit is contained in:
David Taylor 2021-10-26 16:49:45 +01:00
parent b24002018a
commit 54ca7a9618
1 changed files with 6 additions and 1 deletions

View File

@ -415,9 +415,14 @@ export default class PresenceService extends Service {
.filter((e) => e.type === "leave")
.map((e) => e.channel);
channelsToLeave.push(...this._presentChannels);
if (channelsToLeave.length === 0) {
return;
}
const data = new FormData();
data.append("client_id", this.messageBus.clientId);
this._presentChannels.forEach((ch) => data.append("leave_channels[]", ch));
channelsToLeave.forEach((ch) => data.append("leave_channels[]", ch));
data.append("authenticity_token", Session.currentProp("csrfToken"));