Skip to content

Commit bb98aba

Browse files
committed
Prevent attempting to enter fullscreen mode on platforms where it's not supported
1 parent cfa67c4 commit bb98aba

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

packages/webamp/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- 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.
2323
- Avoid a console log from Redux Dev Tools.
2424
- Don't show Milkdrop window option in context menu if Milkdrop is not enabled.
25+
- Fix bug on iPhone where Milkdrop window would resize incorrectly if you attempted to enter fullscreen mode, which is not supported on iPhones.
2526

2627
## 2.1.2 [CURRENT]
2728

packages/webamp/js/components/MilkdropWindow/MilkdropContextMenu.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { Hr, Node } from "../ContextMenu";
33
import { WINDOWS } from "../../constants";
44
import * as Selectors from "../../selectors";
55
import * as Actions from "../../actionCreators";
6-
import ContextMenuWraper from "../ContextMenuWrapper";
6+
import ContextMenuWrapper from "../ContextMenuWrapper";
77
import { useTypedSelector, useActionCreator } from "../../hooks";
8+
import fscreen from "fscreen";
89

910
interface Props {
1011
children: ReactNode;
@@ -16,16 +17,19 @@ const MilkdropContextMenu = (props: Props) => {
1617
const closeWindow = useActionCreator(Actions.closeWindow);
1718
const toggleDesktop = useActionCreator(Actions.toggleMilkdropDesktop);
1819
const toggleFullscreen = useActionCreator(Actions.toggleMilkdropFullscreen);
20+
1921
return (
20-
<ContextMenuWraper
22+
<ContextMenuWrapper
2123
renderContents={() => {
2224
return (
2325
<>
24-
<Node
25-
onClick={toggleFullscreen}
26-
label="Fullscreen"
27-
hotkey="Alt+Enter"
28-
/>
26+
{fscreen.fullscreenEnabled && (
27+
<Node
28+
onClick={toggleFullscreen}
29+
label="Fullscreen"
30+
hotkey="Alt+Enter"
31+
/>
32+
)}
2933
<Node
3034
onClick={toggleDesktop}
3135
checked={desktop}
@@ -39,7 +43,7 @@ const MilkdropContextMenu = (props: Props) => {
3943
}}
4044
>
4145
{props.children}
42-
</ContextMenuWraper>
46+
</ContextMenuWrapper>
4347
);
4448
};
4549

packages/webamp/js/components/MilkdropWindow/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import PresetOverlay from "./PresetOverlay";
1818
import DropTarget from "../DropTarget";
1919
import MilkdropContextMenu from "./MilkdropContextMenu";
2020
import Desktop from "./Desktop";
21+
import fscreen from "fscreen";
2122

2223
const MILLISECONDS_BETWEEN_PRESET_TRANSITIONS = 15000;
2324

@@ -111,6 +112,12 @@ function Milkdrop({ analyser }: Props) {
111112
const screenSize = useScreenSize();
112113
const windowSize = useWindowSize();
113114

115+
const toggleFullScreenIfEnabled = useCallback(() => {
116+
if (fscreen.fullscreenEnabled) {
117+
toggleFullscreen();
118+
}
119+
}, [toggleFullscreen]);
120+
114121
if (desktop) {
115122
return (
116123
<Desktop>
@@ -138,7 +145,7 @@ function Milkdrop({ analyser }: Props) {
138145
>
139146
{overlay && <PresetOverlay {...size} />}
140147
<Fullscreen enabled={fullscreen} onChange={setFullscreen}>
141-
<div onDoubleClick={toggleFullscreen}>
148+
<div onDoubleClick={toggleFullScreenIfEnabled}>
142149
<Visualizer {...size} analyser={analyser} />
143150
</div>
144151
</Fullscreen>

0 commit comments

Comments
 (0)