fix: Fix multiple bugs with new authentication flow
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import type { VoiceState } from '../../../../shared-kernel';
|
||||
|
||||
export function isLocalVoiceOwner(
|
||||
voiceState: Pick<VoiceState, 'isConnected' | 'clientInstanceId'> | null | undefined,
|
||||
clientInstanceId: string
|
||||
): boolean {
|
||||
return !!voiceState?.isConnected
|
||||
&& !!voiceState.clientInstanceId
|
||||
&& voiceState.clientInstanceId === clientInstanceId;
|
||||
}
|
||||
|
||||
export function isVoiceOnAnotherClient(
|
||||
voiceState: Pick<VoiceState, 'isConnected' | 'clientInstanceId'> | null | undefined,
|
||||
clientInstanceId: string
|
||||
): boolean {
|
||||
return !!voiceState?.isConnected
|
||||
&& !!voiceState.clientInstanceId
|
||||
&& voiceState.clientInstanceId !== clientInstanceId;
|
||||
}
|
||||
|
||||
export function shouldTransmitVoice(
|
||||
voiceState: Pick<VoiceState, 'isConnected' | 'clientInstanceId'> | null | undefined,
|
||||
clientInstanceId: string
|
||||
): boolean {
|
||||
if (!voiceState?.isConnected) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!voiceState.clientInstanceId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return voiceState.clientInstanceId === clientInstanceId;
|
||||
}
|
||||
Reference in New Issue
Block a user