mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-27 07:52: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.status = VoiceStatus.UNLOADED;
|
||||||
this.participants = new Map();
|
this.participants = new Map();
|
||||||
|
|
||||||
|
this.syncState = this.syncState.bind(this);
|
||||||
|
this.connect = this.connect.bind(this);
|
||||||
|
this.disconnect = this.disconnect.bind(this);
|
||||||
|
|
||||||
makeAutoObservable(this, {
|
makeAutoObservable(this, {
|
||||||
client: false,
|
client: false,
|
||||||
connecting: false,
|
connecting: false,
|
||||||
|
@ -58,6 +62,13 @@ class VoiceStateReference {
|
||||||
const { default: VoiceClient } = await import("./VoiceClient");
|
const { default: VoiceClient } = await import("./VoiceClient");
|
||||||
const client = new 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(() => {
|
runInAction(() => {
|
||||||
if (!client.supported()) {
|
if (!client.supported()) {
|
||||||
this.status = VoiceStatus.UNAVAILABLE;
|
this.status = VoiceStatus.UNAVAILABLE;
|
||||||
|
@ -91,6 +102,7 @@ class VoiceStateReference {
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.client.authenticate(call.token);
|
await this.client.authenticate(call.token);
|
||||||
|
this.syncState();
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.status = VoiceStatus.RTC_CONNECTING;
|
this.status = VoiceStatus.RTC_CONNECTING;
|
||||||
|
@ -117,12 +129,11 @@ class VoiceStateReference {
|
||||||
|
|
||||||
// Disconnect from current channel.
|
// Disconnect from current channel.
|
||||||
@action disconnect() {
|
@action disconnect() {
|
||||||
if (!this.client?.supported()) throw new Error("RTC is unavailable");
|
|
||||||
|
|
||||||
this.connecting = false;
|
this.connecting = false;
|
||||||
this.status = VoiceStatus.READY;
|
this.status = VoiceStatus.READY;
|
||||||
|
|
||||||
this.client.disconnect();
|
this.client?.disconnect();
|
||||||
|
this.syncState();
|
||||||
}
|
}
|
||||||
|
|
||||||
isProducing(type: ProduceType) {
|
isProducing(type: ProduceType) {
|
||||||
|
|
Loading…
Reference in a new issue