Skip to content

Commit 9062561

Browse files
committed
Hide milkdrop context window if not enabled
1 parent b666670 commit 9062561

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

packages/webamp/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- Fix bug where scrolling the main window or playlist window would change the volume but also (incorrectly) scroll the page.
2121
- Fix bug where resizing the window such that the current layout cannot fit on the page, while also scrolled down the page, would cause the layout to be recentered out of view.
2222
- Avoid a console log from Redux Dev Tools.
23+
- Don't show Milkdrop window option in context menu if Milkdrop is not enabled.
2324

2425
## 2.1.2 [CURRENT]
2526

packages/webamp/js/components/MainWindow/MainContextMenu.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { memo, Fragment, useEffect } from "react";
22
import * as Actions from "../../actionCreators";
33
import * as Selectors from "../../selectors";
4-
import { LOAD_STYLE } from "../../constants";
4+
import { LOAD_STYLE, WINDOWS } from "../../constants";
55
import { Hr, Node, Parent, LinkNode } from "../ContextMenu";
66
import PlaybackContextMenu from "../PlaybackContextMenu";
77
import OptionsContextMenu from "../OptionsContextMenu";
@@ -24,6 +24,8 @@ const MainContextMenu = memo(({ filePickers }: Props) => {
2424
const menuOpened = useActionCreator(() => ({
2525
type: "MAIN_CONTEXT_MENU_OPENED",
2626
}));
27+
const isMilkdropEnabled = useTypedSelector(Selectors.getMilkdropEnabled);
28+
2729
useEffect(() => {
2830
menuOpened();
2931
}, [menuOpened]);
@@ -59,15 +61,20 @@ const MainContextMenu = memo(({ filePickers }: Props) => {
5961
)}
6062
</Parent>
6163
<Hr />
62-
{Object.keys(genWindows).map((i) => (
63-
<Node
64-
key={i}
65-
label={genWindows[i].title}
66-
checked={genWindows[i].open}
67-
onClick={() => toggleWindow(i as WindowId)}
68-
hotkey={genWindows[i].hotkey}
69-
/>
70-
))}
64+
{Object.keys(genWindows).map((i) => {
65+
if (i === WINDOWS.MILKDROP && !isMilkdropEnabled) {
66+
return null;
67+
}
68+
return (
69+
<Node
70+
key={i}
71+
label={genWindows[i].title}
72+
checked={genWindows[i].open}
73+
onClick={() => toggleWindow(i as WindowId)}
74+
hotkey={genWindows[i].hotkey}
75+
/>
76+
);
77+
})}
7178
<Hr />
7279
<SkinsContextMenu />
7380
<Hr />

packages/webamp/js/reducers/windows.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export interface WindowsState {
4040
browserWindowSize: { height: number; width: number };
4141
positionsAreRelative: boolean;
4242
windowOrder: WindowId[];
43+
milkdropEnabled: boolean;
4344
}
4445

4546
const defaultWindowsState: WindowsState = {
@@ -98,6 +99,7 @@ const defaultWindowsState: WindowsState = {
9899
WINDOWS.MILKDROP,
99100
WINDOWS.MAIN,
100101
],
102+
milkdropEnabled: false,
101103
};
102104

103105
const windows = (
@@ -108,6 +110,7 @@ const windows = (
108110
case ENABLE_MILKDROP:
109111
return {
110112
...state,
113+
milkdropEnabled: true,
111114
genWindows: {
112115
...state.genWindows,
113116
[WINDOWS.MILKDROP]: {

packages/webamp/js/selectors.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,11 @@ export function getMilkdropMessage(state: AppState): MilkdropMessage | null {
687687
return state.milkdrop.message;
688688
}
689689

690+
// Has Butterchurn been injected?
691+
export function getMilkdropEnabled(state: AppState): boolean {
692+
return state.windows.milkdropEnabled;
693+
}
694+
690695
export function getMilkdropWindowEnabled(state: AppState): boolean {
691696
return state.milkdrop.display === "WINDOW";
692697
}

0 commit comments

Comments
 (0)