Skip to content

Commit

Permalink
pause playback when settings page is opened, and don't reload frames …
Browse files Browse the repository at this point in the history
…afterwards (#64)
  • Loading branch information
robbles authored Oct 5, 2022
1 parent 32474dc commit 71e9ab4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/components/game.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,19 @@ class Game extends React.Component {
this.props.toggleTheme(options.theme);
}

if (options.game && options.engine) {
this.hideLogo = options.hideLogo === "true";
this.hideScoreboard = options.hideScoreboard === "true";
this.showFrameScrubber = options.showFrameScrubber;
this.title = options.title && decodeURIComponent(options.title);
this.props.setGameOptions(options);
this.props.fetchFrames();
} else {
if (!(options.game && options.engine)) {
this.invalidArgs = true;
return;
}

this.hideLogo = options.hideLogo === "true";
this.hideScoreboard = options.hideScoreboard === "true";
this.showFrameScrubber = options.showFrameScrubber;
this.title = options.title && decodeURIComponent(options.title);
this.props.setGameOptions(options);

if (this.props.frames.length === 0) {
this.props.fetchFrames();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/settings/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import PlaybackSpeed from "./playback/PlaybackSpeed";
import styles from "./SettingsPage.module.css";
import { useHistory } from "react-router-dom";
import { togglePlayButtons, themeChanged } from "../../actions";
import { togglePlayButtons, pauseGame, themeChanged } from "../../actions";

const SettingsPage = () => {
const history = useHistory();
Expand All @@ -25,6 +25,7 @@ const SettingsPage = () => {

useEffect(() => {
dispatch(togglePlayButtons("hide"));
dispatch(pauseGame());
});

function dispatchSpeedChange(fps) {
Expand Down

0 comments on commit 71e9ab4

Please sign in to comment.