Skip to content

Commit

Permalink
Add a pref for pausing on losing page focus (Closes crosshare-org#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamthedog committed Feb 1, 2024
1 parent 1b128a5 commit b2e0179
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/components/Puzzle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ export const Puzzle = ({

// Pause when page goes out of focus
function prodPause() {
if (process.env.NODE_ENV !== 'development') {
if (process.env.NODE_ENV !== 'development' && !props.prefs?.dontPauseOnLostFocus) {

window.parent.postMessage(
{
type: 'pause',
Expand Down Expand Up @@ -1204,7 +1205,15 @@ export const Puzzle = ({
text="Start puzzles in downs-only mode"
/>
</li>

<li>
<PrefSetting
prefs={props.prefs}
userId={props.user!.uid}
flag={'dontPauseOnLostFocus'}
invert={true}
text="Pause solving when clicking away from the page"
/>
</li>
</ul>
}
</NestedDropDown>
Expand Down
1 change: 1 addition & 0 deletions app/lib/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const AccountPrefsFlagsV = t.partial({
dontAdvanceWordAfterCompletion: t.boolean,
solveDownsOnly: t.boolean,
disableCommentsByDefault: t.boolean,
dontPauseOnLostFocus: t.boolean
});
export type AccountPrefsFlagsT = t.TypeOf<typeof AccountPrefsFlagsV>;

Expand Down
9 changes: 9 additions & 0 deletions app/pages/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,15 @@ export const AccountPage = ({ user, constructorPage, prefs }: AuthProps) => {
text="Start puzzles in downs-only mode"
/>
</li>
<li>
<PrefSetting
prefs={prefs}
userId={user.uid}
flag={'dontPauseOnLostFocus'}
invert={true}
text="Pause solving when clicking away from the page"
/>
</li>
</ul>
<hr css={{ margin: '2em 0' }} />
<h2>Browser-specific Settings</h2>
Expand Down

0 comments on commit b2e0179

Please sign in to comment.