Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Join/Leave sounds don't play for you when you join/leave #761

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/lib/vortex/VoiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from "./Types";

const UnsupportedError = types.UnsupportedError;
const state = useApplicationState();

interface VoiceEvents {
ready: () => void;
Expand Down Expand Up @@ -60,8 +61,6 @@ export default class VoiceClient extends EventEmitter<VoiceEvents> {

this.isDeaf = false;

const state = useApplicationState();

this.signaling.on(
"data",
(json) => {
Expand Down Expand Up @@ -174,6 +173,8 @@ export default class VoiceClient extends EventEmitter<VoiceEvents> {
this.sendTransport = undefined;
this.recvTransport = undefined;

state.settings.sounds.playSound("call_leave");

this.emit("close", error);
}

Expand Down
7 changes: 7 additions & 0 deletions src/pages/channels/voice/VoiceHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { Button } from "@revoltchat/ui";

import { voiceState, VoiceStatus } from "../../../lib/vortex/VoiceState";

import { useApplicationState } from "../../../mobx/State";

import Tooltip from "../../../components/common/Tooltip";
import UserIcon from "../../../components/common/user/UserIcon";
import { useClient } from "../../../controllers/client/ClientController";
Expand Down Expand Up @@ -85,13 +87,18 @@ export default observer(({ id }: Props) => {

const client = useClient();
const self = client.users.get(client.user!._id);
const state = useApplicationState();

const keys = Array.from(voiceState.participants.keys());
const users = useMemo(() => {
return keys.map((key) => client.users.get(key));
// eslint-disable-next-line
}, [keys]);

if (voiceState.connecting) {
state.settings.sounds.playSound("call_join");
}
Comment on lines +98 to +100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any re-render would cause the sound to play more than once here, I think this should be moved somewhere else.


return (
<VoiceBase>
<div className="participants">
Expand Down