Skip to content

Commit

Permalink
fix: per video volume boost was disabled when adjusting boost
Browse files Browse the repository at this point in the history
  • Loading branch information
VampireChicken12 committed Jan 22, 2024
1 parent 2000303 commit daef94c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
15 changes: 14 additions & 1 deletion src/pages/content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ import { addScreenshotButton, removeScreenshotButton } from "@/src/features/scre
import adjustSpeedOnScrollWheel from "@/src/features/scrollWheelSpeedControl";
import adjustVolumeOnScrollWheel from "@/src/features/scrollWheelVolumeControl";
import { promptUserToResumeVideo, setupVideoHistory } from "@/src/features/videoHistory";
import volumeBoost, { addVolumeBoostButton, disableVolumeBoost, enableVolumeBoost, removeVolumeBoostButton } from "@/src/features/volumeBoost";
import volumeBoost, {
addVolumeBoostButton,
applyVolumeBoost,
disableVolumeBoost,
enableVolumeBoost,
removeVolumeBoostButton
} from "@/src/features/volumeBoost";
import { i18nService } from "@/src/i18n";
import eventManager from "@/utils/EventManager";
import {
Expand Down Expand Up @@ -166,6 +172,13 @@ window.addEventListener("DOMContentLoaded", function () {
}
break;
}
case "volumeBoostAmountChange": {
const {
data: { volumeBoostAmount }
} = message;
applyVolumeBoost(volumeBoostAmount);
break;
}
case "playerSpeedChange": {
const {
data: { enableForcedPlaybackSpeed, playerSpeed }
Expand Down
8 changes: 2 additions & 6 deletions src/pages/inject/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ const storageChangeHandler = async (changes: StorageChanges, areaName: string) =
},
enable_volume_boost: (newValue) => {
sendExtensionOnlyMessage("volumeBoostChange", {
volumeBoostAmount: options.volume_boost_amount,
volumeBoostEnabled: newValue,
volumeBoostMode: options.volume_boost_mode
});
Expand All @@ -293,15 +292,12 @@ const storageChangeHandler = async (changes: StorageChanges, areaName: string) =
});
},
volume_boost_amount: (newValue) => {
sendExtensionOnlyMessage("volumeBoostChange", {
volumeBoostAmount: newValue,
volumeBoostEnabled: options.enable_volume_boost,
volumeBoostMode: options.volume_boost_mode
sendExtensionOnlyMessage("volumeBoostAmountChange", {
volumeBoostAmount: newValue
});
},
volume_boost_mode: (newValue) => {
sendExtensionOnlyMessage("volumeBoostChange", {
volumeBoostAmount: options.volume_boost_amount,
volumeBoostEnabled: options.enable_volume_boost,
volumeBoostMode: newValue
});
Expand Down
6 changes: 2 additions & 4 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,8 @@ export type ExtensionSendOnlyMessageMappings = {
scrollWheelSpeedControlChange: DataResponseMessage<"scrollWheelSpeedControlChange", { scrollWheelSpeedControlEnabled: boolean }>;
scrollWheelVolumeControlChange: DataResponseMessage<"scrollWheelVolumeControlChange", { scrollWheelVolumeControlEnabled: boolean }>;
videoHistoryChange: DataResponseMessage<"videoHistoryChange", { videoHistoryEnabled: boolean }>;
volumeBoostChange: DataResponseMessage<
"volumeBoostChange",
{ volumeBoostAmount?: number; volumeBoostEnabled: boolean; volumeBoostMode: VolumeBoostMode }
>;
volumeBoostAmountChange: DataResponseMessage<"volumeBoostAmountChange", { volumeBoostAmount: number }>;
volumeBoostChange: DataResponseMessage<"volumeBoostChange", { volumeBoostEnabled: boolean; volumeBoostMode: VolumeBoostMode }>;
};
export type FilterMessagesBySource<T extends Messages, S extends MessageSource> = {
[K in keyof T]: Extract<T[K], { source: S }>;
Expand Down

0 comments on commit daef94c

Please sign in to comment.