Skip to content

Commit ec17858

Browse files
committed
fix: consider DMs as voice channels
1 parent a3611e1 commit ec17858

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

src/classes/Channel.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { batch } from "solid-js";
22

3+
import { ReactiveMap } from "@solid-primitives/map";
34
import type { ReactiveSet } from "@solid-primitives/set";
45
import type {
56
Channel as APIChannel,
@@ -29,7 +30,6 @@ import type { Message } from "./Message.js";
2930
import type { Server } from "./Server.js";
3031
import type { ServerMember } from "./ServerMember.js";
3132
import type { User } from "./User.js";
32-
import { ReactiveMap } from "@solid-primitives/map";
3333
import { VoiceParticipant } from "./VoiceParticipant.js";
3434

3535
/**
@@ -317,8 +317,7 @@ export class Channel {
317317
* Get mentions in this channel for user.
318318
*/
319319
get mentions(): ReactiveSet<string> | undefined {
320-
if (this.type === "SavedMessages")
321-
return undefined;
320+
if (this.type === "SavedMessages") return undefined;
322321

323322
return this.#collection.client.channelUnreads.get(this.id)
324323
?.messageMentionIds;
@@ -330,7 +329,11 @@ export class Channel {
330329
* NB. subject to change as vc(2) goes to production
331330
*/
332331
get isVoice(): boolean {
333-
return typeof this.#collection.getUnderlyingObject(this.id).voice === 'object';
332+
return (
333+
this.type === "DirectMessage" ||
334+
this.type === "Group" ||
335+
typeof this.#collection.getUnderlyingObject(this.id).voice === "object"
336+
);
334337
}
335338

336339
/**
@@ -797,18 +800,26 @@ export class Channel {
797800

798801
/**
799802
* Join a call
800-
* @param node Target node
803+
* @param node Target node
801804
* @param forceDisconnect Whether to disconnect existing call
802805
* @param recipients Ring targets
803806
* @returns LiveKit URL and Token
804807
*/
805-
async joinCall(node?: string, forceDisconnect = true, recipients?: (User | string)[]) {
808+
async joinCall(
809+
node?: string,
810+
forceDisconnect = true,
811+
recipients?: (User | string)[],
812+
) {
806813
return await this.#collection.client.api.post(
807-
`/channels/${this.id as ''}/join_call`, {
808-
node,
809-
recipients: recipients?.map(entry => typeof entry === 'string' ? entry : entry.id),
810-
force_disconnect: forceDisconnect
811-
});
814+
`/channels/${this.id as ""}/join_call`,
815+
{
816+
node,
817+
recipients: recipients?.map((entry) =>
818+
typeof entry === "string" ? entry : entry.id,
819+
),
820+
force_disconnect: forceDisconnect,
821+
},
822+
);
812823
}
813824

814825
/**

0 commit comments

Comments
 (0)