From 66f21b1c7ee8e311ee371022a975ed657f9faf97 Mon Sep 17 00:00:00 2001 From: Crawl Date: Sat, 1 Dec 2018 17:46:58 +0100 Subject: [PATCH] fix: partySize --- src/client/RPCClient.ts | 4 ++-- src/structures/Activity.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/client/RPCClient.ts b/src/client/RPCClient.ts index 4a71365..80b3315 100644 --- a/src/client/RPCClient.ts +++ b/src/client/RPCClient.ts @@ -138,8 +138,8 @@ export default class RPCClient implements Disposable { else return this._activity.changePartyId(); }); liveshare.onDidChangePeers(({ added, removed }: { added: vsls.Peer[], removed: vsls.Peer[] }) => { - if (added.length) return this._activity.increasePartySize(); - else if (removed.length) return this._activity.decreasePartySize(); + if (added.length) return this._activity.increasePartySize(added.length); + else if (removed.length) return this._activity.decreasePartySize(removed.length); }); }); diff --git a/src/structures/Activity.ts b/src/structures/Activity.ts index 9c90d90..01da4f4 100644 --- a/src/structures/Activity.ts +++ b/src/structures/Activity.ts @@ -164,23 +164,23 @@ export default class Activity implements Disposable { return this._state; } - public increasePartySize() { - if (!this._state || !this._state.partySize) return; + public increasePartySize(size?: number) { + if (!this._state) return; if (this.state && this._state.partySize === 5) return; this._state = { ...this._state, - partySize: this._state.partySize + 1 + partySize: this._state.partySize ? this._state.partySize + 1 : size }; return this._state; } - public decreasePartySize() { - if (!this._state || !this._state.partySize) return; + public decreasePartySize(size?: number) { + if (!this._state) return; if (this.state && this._state.partySize === 1) return; this._state = { ...this._state, - partySize: this._state.partySize - 1 + partySize: this._state.partySize ? this._state.partySize - 1 : size }; return this._state;