Skip to content
Merged
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
2 changes: 0 additions & 2 deletions app/src/components/ExpandingTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ function ExpandingTextArea({ input, setInput, onKeyDown }: PropsType) {
}
}, [input]);

console.log(filteredMembers);

return (
<StyledMentionsInput>
<MentionsInput
Expand Down
5 changes: 5 additions & 0 deletions app/src/data/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ enum icons {
Group,
CallAccept,
Mention,
UnMute
}

type iconStrings = keyof typeof icons;
Expand Down Expand Up @@ -446,6 +447,10 @@ const iconImports: Record<iconStrings, IconConfig> = {
Mention:{
importFn: () => import ("@mui/icons-material/AlternateEmail"),
},
UnMute: {
importFn: () => import("@mui/icons-material/MicOff"),
defaultProps: { fontSize: "large" },
}
};

const iconCache = new Map<string, React.ReactElement>();
Expand Down
17 changes: 15 additions & 2 deletions app/src/features/calls/CallLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getChatByID } from "@features/chats/utils/helpers";
import { useAppSelector } from "@hooks/useGlobalState";
import { useSocket } from "@hooks/useSocket";
import { EnableSpeaker } from "./SpeakerEnable";
import { useState } from "react";

const ModalContainer = styled.div`
position: fixed;
Expand Down Expand Up @@ -203,12 +204,22 @@ export default function CallLayout({
callStatus
}: PropsType) {
const { acceptCall, finishCall } = useSocket();
const { endCall, chatId } = useCallContext();
const { endCall, chatId, mute, unmute } = useCallContext();
const [isMuted, setIsMuted] = useState(false);
const chats = useAppSelector((state) => state.chats.chats);
const chat = getChatByID({
chatID: chatId.current ?? "",
chats: chats
});
const toggleMute = () => {
if (isMuted) {
setIsMuted(false);
unmute();
} else {
setIsMuted(true);
mute();
}
};

return (
<>
Expand All @@ -233,7 +244,9 @@ export default function CallLayout({
</NameContainer>
<ButtonsContainer>
<ButtonContainer>
<RoundButton>{getIcon("Mute")}</RoundButton>
<RoundButton onClick={toggleMute}>
{isMuted ? getIcon("UnMute") : getIcon("Mute")}
</RoundButton>
<ButtonText>unmute</ButtonText>
</ButtonContainer>
{callStatus === "incoming" && (
Expand Down
11 changes: 10 additions & 1 deletion app/src/features/calls/context/CallProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { CallStatus } from "types/calls";
import { TURN_USERNAME, TURN_PASSWORD } from "@constants";
const Servers = {
iceServers: [
{ urls: ["stun:stun.l.google.com:19302", "stun:stun.l.google.com:5349"] },
{
urls: ["stun:stun1.l.google.com:19302", "stun:stun2.l.google.com:19302"]
},
Expand Down Expand Up @@ -134,6 +133,14 @@ export const CallProvider: React.FC<{ children: ReactNode }> = ({
[clearClientIds, removeClientId, setCallStatus]
);

const mute = () => {
if (localStream.current)
localStream.current.getAudioTracks()[0].enabled = false;
};
const unmute = () => {
if (localStream.current)
localStream.current.getAudioTracks()[0].enabled = true;
};
const acceptCall = useCallback(() => {
if (callIdRef.current && chatIdRef.current) {
if (
Expand Down Expand Up @@ -302,6 +309,8 @@ export const CallProvider: React.FC<{ children: ReactNode }> = ({
endCall,
recieveICE,
recieveAnswer,
mute,
unmute,
getPeerConnection
};

Expand Down
3 changes: 1 addition & 2 deletions app/src/features/chats/hooks/useChatInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ function useChatInput() {
setIsEmojiSelectorOpen(false);
};

const handleSubmit = (e: Event, voiceNoteName = "") => {
console.log(voiceNoteName);
const handleSubmit = (e: Event) => {
e.preventDefault();
setIsEmojiSelectorOpen(false);
if (isRecording !== "idle") return;
Expand Down
3 changes: 3 additions & 0 deletions app/src/types/calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export interface CallContextType {
joinCall: (newCallId: string, newSenderId: string, newChatId: string) => void;
endCall: (clientId: string | null) => void;

mute: () => void;
unmute: () => void;

acceptCall: () => void;
startPeerConnection: (
clientId: string
Expand Down