fix: partySize

This commit is contained in:
Crawl 2018-12-01 17:46:58 +01:00
parent c424499a96
commit 66f21b1c7e
No known key found for this signature in database
GPG key ID: E41A6DB922EC2CFE
2 changed files with 8 additions and 8 deletions

View file

@ -138,8 +138,8 @@ export default class RPCClient implements Disposable {
else return this._activity.changePartyId(); else return this._activity.changePartyId();
}); });
liveshare.onDidChangePeers(({ added, removed }: { added: vsls.Peer[], removed: vsls.Peer[] }) => { liveshare.onDidChangePeers(({ added, removed }: { added: vsls.Peer[], removed: vsls.Peer[] }) => {
if (added.length) return this._activity.increasePartySize(); if (added.length) return this._activity.increasePartySize(added.length);
else if (removed.length) return this._activity.decreasePartySize(); else if (removed.length) return this._activity.decreasePartySize(removed.length);
}); });
}); });

View file

@ -164,23 +164,23 @@ export default class Activity implements Disposable {
return this._state; return this._state;
} }
public increasePartySize() { public increasePartySize(size?: number) {
if (!this._state || !this._state.partySize) return; if (!this._state) return;
if (this.state && this._state.partySize === 5) return; if (this.state && this._state.partySize === 5) return;
this._state = { this._state = {
...this._state, ...this._state,
partySize: this._state.partySize + 1 partySize: this._state.partySize ? this._state.partySize + 1 : size
}; };
return this._state; return this._state;
} }
public decreasePartySize() { public decreasePartySize(size?: number) {
if (!this._state || !this._state.partySize) return; if (!this._state) return;
if (this.state && this._state.partySize === 1) return; if (this.state && this._state.partySize === 1) return;
this._state = { this._state = {
...this._state, ...this._state,
partySize: this._state.partySize - 1 partySize: this._state.partySize ? this._state.partySize - 1 : size
}; };
return this._state; return this._state;