Skip to content

Commit

Permalink
fix setting race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
teticio committed Oct 1, 2021
1 parent f9c7406 commit bd66db6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
14 changes: 7 additions & 7 deletions src/components/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRoutes = (
waypoints, setWaypoints,
size, setSize,
creativity, setCreativity,
noise, setNoise,
noise, setNoise,
playlist, setPlaylist,
spotify, navigate, numPlaylists
) => {
Expand All @@ -27,12 +27,12 @@ export const getRoutes = (
noise: noise,
spotify: spotify,
onCreate: (playlist, waypoints) => {
setWaypoints(() => waypoints);
setPlaylist(() => playlist);
setWaypoints(waypoints);
setPlaylist(playlist);
navigate('/playlist');
},
onSettings: waypoints => {
setWaypoints(() => waypoints);
setWaypoints(waypoints);
navigate('/settings');
}
},
Expand All @@ -51,9 +51,9 @@ export const getRoutes = (
creativity: creativity,
noise: noise,
onChange: (size, creativity, noise) => {
setSize(() => { return size !== '' ? size : 0; });
setCreativity(() => creativity);
setNoise(() => noise);
setSize(size !== '' ? size : 0);
setCreativity(creativity);
setNoise(noise);
},
onClose: () => navigate('/')
},
Expand Down
5 changes: 4 additions & 1 deletion src/components/Platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
import { MdStar, MdStarHalf, MdStarBorder } from 'react-icons/md';
import { Container, Card, Spinner, Form, Navbar, Nav } from 'react-bootstrap';

export { FaPlus, FaForward, FaBackward, FaCloudUploadAlt, FaPen, FaSpotify, FaCog, FaSearch, FaTimes };
export {
FaPlus, FaForward, FaBackward, FaCloudUploadAlt,
FaPen, FaSpotify, FaCog, FaSearch, FaTimes
};
export { MdStar, MdStarHalf, MdStarBorder };
export { Container, Card, Spinner, Form, Navbar, Nav };

Expand Down
1 change: 1 addition & 0 deletions src/components/Platform.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export function FaForward(props) {
export function FaBackward(props) {
return <FaIcon name='backward' {...props} />
}

export function FaCloudUploadAlt(props) {
return <FaIcon name='cloud-upload-alt' {...props} />
}
Expand Down
26 changes: 5 additions & 21 deletions src/components/Settings.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState } from 'react';
import { Card, Text, Small, Form, FaBackward, Hr } from './Platform';
import { Row, Col, HorizontalSpacer, VerticalSpacer } from './Lib';

Expand All @@ -12,14 +12,11 @@ export default function Settings({ size, creativity, noise, onChange = f => f, o
const validateSize = (value) => {
if (value && value !== '') {
setValidSize(value);
update();
} else {
setSize('');
}
}

useEffect(() => () => update());

return (
<>
<VerticalSpacer />
Expand All @@ -39,7 +36,6 @@ export default function Settings({ size, creativity, noise, onChange = f => f, o
onBlur={event => {
if (event.target.value) {
setValidSize(event.target.value);
update();
}
}}
/>
Expand All @@ -63,14 +59,8 @@ export default function Settings({ size, creativity, noise, onChange = f => f, o
max='1'
step='0.01'
value={_creativity}
onChange={event => {
setCreativity(event.target.value);
update();
}}
onValueChange={value => {
setCreativity(value);
update();
}}
onChange={event => setCreativity(event.target.value)}
onValueChange={value => setCreativity(value)}
/>
</Col>
</Row>
Expand All @@ -93,14 +83,8 @@ export default function Settings({ size, creativity, noise, onChange = f => f, o
max='1'
step='0.01'
value={_noise}
onChange={event => {
setNoise(event.target.value);
update();
}}
onValueChange={value => {
setNoise(value);
update();
}}
onChange={event => setNoise(event.target.value)}
onValueChange={value => setNoise(value)}
/>
</Col>
</Row>
Expand Down

0 comments on commit bd66db6

Please sign in to comment.