mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-26 15:32:11 -05:00
Fix new state updates.
This commit is contained in:
parent
4ec1ff5c59
commit
7d76a657fa
1 changed files with 14 additions and 3 deletions
|
@ -34,6 +34,10 @@ class VoiceStateReference {
|
|||
this.status = VoiceStatus.UNLOADED;
|
||||
this.participants = new Map();
|
||||
|
||||
this.syncState = this.syncState.bind(this);
|
||||
this.connect = this.connect.bind(this);
|
||||
this.disconnect = this.disconnect.bind(this);
|
||||
|
||||
makeAutoObservable(this, {
|
||||
client: false,
|
||||
connecting: false,
|
||||
|
@ -58,6 +62,13 @@ class VoiceStateReference {
|
|||
const { default: VoiceClient } = await import("./VoiceClient");
|
||||
const client = new VoiceClient();
|
||||
|
||||
client.on("startProduce", this.syncState);
|
||||
client.on("stopProduce", this.syncState);
|
||||
client.on("userJoined", this.syncState);
|
||||
client.on("userLeft", this.syncState);
|
||||
client.on("userStartProduce", this.syncState);
|
||||
client.on("userStopProduce", this.syncState);
|
||||
|
||||
runInAction(() => {
|
||||
if (!client.supported()) {
|
||||
this.status = VoiceStatus.UNAVAILABLE;
|
||||
|
@ -91,6 +102,7 @@ class VoiceStateReference {
|
|||
});
|
||||
|
||||
await this.client.authenticate(call.token);
|
||||
this.syncState();
|
||||
|
||||
runInAction(() => {
|
||||
this.status = VoiceStatus.RTC_CONNECTING;
|
||||
|
@ -117,12 +129,11 @@ class VoiceStateReference {
|
|||
|
||||
// Disconnect from current channel.
|
||||
@action disconnect() {
|
||||
if (!this.client?.supported()) throw new Error("RTC is unavailable");
|
||||
|
||||
this.connecting = false;
|
||||
this.status = VoiceStatus.READY;
|
||||
|
||||
this.client.disconnect();
|
||||
this.client?.disconnect();
|
||||
this.syncState();
|
||||
}
|
||||
|
||||
isProducing(type: ProduceType) {
|
||||
|
|
Loading…
Reference in a new issue