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

Feat: [non-ios] control volume of line #243

Merged
merged 27 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
db21327
feat: control volume of line
Saelmala Dec 9, 2024
7804794
fix: remove duplicate outputs
Saelmala Dec 9, 2024
af31a28
fix: testing
Saelmala Dec 9, 2024
7211ce6
fix: testing
Saelmala Dec 9, 2024
24c9cd7
fix: change to use element instead of context
Saelmala Dec 10, 2024
b1a3cc1
fix: ui colume buttons on mobile fix
Saelmala Dec 11, 2024
e4a0026
test: ios mobile test
Saelmala Dec 11, 2024
c508a0c
test: ios mobile volume
Saelmala Dec 11, 2024
0e3e672
test: add log
Saelmala Dec 11, 2024
9277b99
test: iphone volume control
Saelmala Dec 12, 2024
5d21c18
test: iphone volume control
Saelmala Dec 12, 2024
60202ff
test: logs for iphone volume control
Saelmala Dec 12, 2024
104086b
test: logs iphone volume control
Saelmala Dec 12, 2024
5bfb75f
test: iphone volume control
Saelmala Dec 12, 2024
5a9d06e
test: volume control ios
Saelmala Dec 12, 2024
b85365f
test: logging gainNode.gain.value after assign
Saelmala Dec 12, 2024
e5511eb
test: ios issues
Saelmala Dec 12, 2024
9e9bfd0
test: ios problems
Saelmala Dec 12, 2024
6acd8b9
test: iphone volume problems
Saelmala Dec 12, 2024
ff1f60c
test: ios volume control
Saelmala Dec 12, 2024
ae8546d
test: iphone volume control
Saelmala Dec 12, 2024
1d35b3b
fix: remove non-working code
Saelmala Dec 13, 2024
d2cfe59
Merge branch 'development' into feat-control-volume-of-line
Saelmala Dec 13, 2024
b851980
fix: small updates
Saelmala Dec 16, 2024
4946fa7
fix: ui fixes
Saelmala Dec 16, 2024
95058e6
fix: remove added line
Saelmala Dec 16, 2024
8250ad0
fixup!
Saelmala Dec 16, 2024
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
3 changes: 3 additions & 0 deletions src/assets/icons/full_sound.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/assets/icons/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import ConfirmSvg from "./done.svg?react";
import StepLeftSvg from "./chevron_left.svg?react";
import StepRightSvg from "./navigate_next.svg?react";
import Settings from "./settings.svg?react";
import NoSound from "./no_sound.svg?react";
import FullSound from "./full_sound.svg?react";
import Minus from "./minus.svg?react";
import Plus from "./plus.svg?react";
import ChevronDown from "./chevron_down.svg?react";
import ChevronUp from "./chevron_up.svg?react";
import Headset from "./headset.svg?react";
Expand All @@ -35,6 +39,14 @@ export const StepRightIcon = () => <StepRightSvg />;

export const SettingsIcon = () => <Settings />;

export const NoSoundIcon = () => <NoSound />;

export const FullSoundIcon = () => <FullSound />;

export const MinusIcon = () => <Minus />;

export const PlusIcon = () => <Plus />;

export const ChevronDownIcon = () => <ChevronDown />;

export const ChevronUpIcon = () => <ChevronUp />;
Expand Down
3 changes: 3 additions & 0 deletions src/assets/icons/minus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/no_sound.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/components/production-line/exit-call-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const StyledBackBtn = styled(PrimaryButton)`
padding: 0;
margin: 0;
width: 4rem;
background: #32383b;
border: 0.2rem solid #6d6d6d;
`;

export const ExitCallButton = ({
Expand Down
32 changes: 26 additions & 6 deletions src/components/production-line/production-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { useCheckBadLineData } from "./use-check-bad-line-data.ts";
import { useAudioCue } from "./use-audio-cue.ts";
import { DisplayWarning } from "../display-box.tsx";
import { SettingsModal, Hotkeys } from "./settings-modal.tsx";
import { VolumeSlider } from "../volume-slider/volume-slider.tsx";
import { CallState } from "../../global-state/types.ts";
import { ExitCallButton } from "./exit-call-button.tsx";
import { Modal } from "../modal/modal.tsx";
Expand Down Expand Up @@ -74,11 +75,11 @@ const FlexButtonWrapper = styled.div`
width: 50%;
padding: 0 1rem 2rem 1rem;

:first-of-type {
&.first {
padding-left: 0;
}

:last-of-type {
&.last {
padding-right: 0;
}
`;
Expand Down Expand Up @@ -145,11 +146,15 @@ export const ProductionLine = ({
muteHotkey: "m",
speakerHotkey: "n",
pressToTalkHotkey: "t",
increaseVolumeHotkey: "u",
decreaseVolumeHotkey: "d",
});
const [savedHotkeys, setSavedHotkeys] = useState<Hotkeys>({
muteHotkey: "m",
speakerHotkey: "n",
pressToTalkHotkey: "t",
increaseVolumeHotkey: "u",
decreaseVolumeHotkey: "d",
});
const {
joinProductionOptions,
Expand Down Expand Up @@ -333,18 +338,21 @@ export const ProductionLine = ({
}}
>
<DisplayContainerHeader>Controls</DisplayContainerHeader>

<VolumeSlider
audioElements={audioElements || []}
increaseVolumeKey={savedHotkeys.increaseVolumeHotkey}
decreaseVolumeKey={savedHotkeys.decreaseVolumeHotkey}
/>
<FlexContainer>
<FlexButtonWrapper>
<FlexButtonWrapper className="first">
<UserControlBtn type="button" onClick={() => muteOutput()}>
<ButtonIcon>
{isOutputMuted ? <SpeakerOff /> : <SpeakerOn />}
</ButtonIcon>
</UserControlBtn>
</FlexButtonWrapper>

{inputAudioStream && inputAudioStream !== "no-device" && (
<FlexButtonWrapper>
<FlexButtonWrapper className="last">
<UserControlBtn
type="button"
onClick={() => muteInput(!isInputMuted)}
Expand Down Expand Up @@ -401,6 +409,18 @@ export const ProductionLine = ({
</strong>
Push to Talk
</TempDiv>
<TempDiv>
<strong>
{savedHotkeys.increaseVolumeHotkey.toUpperCase()}:{" "}
</strong>
Increase Volume
</TempDiv>
<TempDiv>
<strong>
{savedHotkeys.decreaseVolumeHotkey.toUpperCase()}:{" "}
</strong>
Decrease Volume
</TempDiv>
{isSettingsModalOpen && (
<SettingsModal
hotkeys={hotkeys}
Expand Down
103 changes: 80 additions & 23 deletions src/components/production-line/settings-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export type Hotkeys = {
muteHotkey: string;
speakerHotkey: string;
pressToTalkHotkey: string;
increaseVolumeHotkey: string;
decreaseVolumeHotkey: string;
};

type TSettingsModalProps = {
Expand All @@ -74,6 +76,7 @@ type TSettingsModalProps = {
onClose: () => void;
onSave: () => void;
};

export const SettingsModal = ({
hotkeys,
lineName,
Expand All @@ -87,39 +90,39 @@ export const SettingsModal = ({
muteHotkey: "",
speakerHotkey: "",
pressToTalkHotkey: "",
increaseVolumeHotkey: "",
decreaseVolumeHotkey: "",
});

const validateFields = (key: string, value: string) => {
const validateFields = (key: keyof Hotkeys, value: string) => {
const currentValues = {
...hotkeys,
[key]: value,
};

const duplicates = Object.entries(currentValues).reduce(
(acc, [field, val]) => {
if (val && value && val === value && field !== key) {
acc[key] = "This key is already in use.";
const newErrors = (
Object.keys(currentValues) as Array<keyof Hotkeys>
).reduce(
(acc, field) => {
const isDuplicate =
Object.values(currentValues).filter(
(val) => val && val === currentValues[field]
).length > 1;

if (!currentValues[field]) {
acc[field] = "This field can not be empty.";
} else if (isDuplicate) {
acc[field] = "This key is already in use.";
} else {
acc[field] = "";
}

return acc;
},
{} as { [key: string]: string }
{} as { [K in keyof Hotkeys]: string }
);

setErrors((prevErrors) => ({
...prevErrors,
muteHotkey:
key === "muteHotkey"
? duplicates.muteHotkey || ""
: prevErrors.muteHotkey,
speakerHotkey:
key === "speakerHotkey"
? duplicates.speakerHotkey || ""
: prevErrors.speakerHotkey,
pressToTalkHotkey:
key === "pressToTalkHotkey"
? duplicates.pressToTalkHotkey || ""
: prevErrors.pressToTalkHotkey,
}));
setErrors(newErrors);
};

const handleInputChange = (key: keyof typeof hotkeys, value: string) => {
Expand All @@ -134,9 +137,13 @@ export const SettingsModal = ({

const handleSave = () => {
const hasErrors = Object.values(errors).some((error) => error !== "");
if (!hasErrors) {
onSave();
const hasEmptyFields = Object.values(hotkeys).some((value) => !value);

if (hasErrors || hasEmptyFields) {
return;
}

onSave();
};

const handleKeyDown = (e: React.KeyboardEvent, index: number) => {
Expand Down Expand Up @@ -237,6 +244,56 @@ export const SettingsModal = ({
/>
)}
</FormLabel>
<FormLabel>
<DecorativeLabel>Increase volume:</DecorativeLabel>
<FormInput
id="increaseVolume"
ref={(el) => setInputRef(3, el)}
type="text"
value={hotkeys.increaseVolumeHotkey}
onChange={(e) =>
handleInputChange("increaseVolumeHotkey", e.target.value)
}
placeholder="Enter hotkey"
maxLength={1}
onKeyDown={(e) => handleKeyDown(e, 3)}
/>
{errors.increaseVolumeHotkey && (
<ErrorMessage
errors={{
increasevolumekey: { message: errors.increaseVolumeHotkey },
}}
name="increasevolumekey"
as={StyledWarningMessage}
/>
)}
</FormLabel>
<FormLabel>
<DecorativeLabel>Decrease volume:</DecorativeLabel>
<FormInput
id="decreaseVolume"
ref={(el) => setInputRef(4, el)}
type="text"
value={hotkeys.decreaseVolumeHotkey}
onChange={(e) =>
handleInputChange("decreaseVolumeHotkey", e.target.value)
}
placeholder="Enter hotkey"
maxLength={1}
onKeyDown={(e) => handleKeyDown(e, 4)}
/>
{errors.decreaseVolumeHotkey && (
<ErrorMessage
errors={{
decreasevolumehotkey: {
message: errors.decreaseVolumeHotkey,
},
}}
name="decreasevolumehotkey"
as={StyledWarningMessage}
/>
)}
</FormLabel>
<ButtonDiv>
<CancelButton type="button" onClick={onClose}>
Cancel
Expand Down
Loading
Loading