Fixed refresh interval adjustment

This commit is contained in:
Matthew Garrett 2022-05-19 20:22:30 -07:00
Родитель 4fe2aad1a8
Коммит c82bd356ff
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -47,14 +47,17 @@ export default function UserSettings(props) {
const [refreshValue, setRefreshValue] = React.useState();
const [sending, setSending] = React.useState(false);
const [changed, setChanged] = React.useState(false);
const refreshInterval = useSelector(getRefreshInterval);
const unchanged = refreshInterval == refreshValue;
React.useEffect(()=>{
setRefreshValue(refreshInterval);
}, []);
React.useEffect(()=>{
refreshInterval == refreshValue ? setChanged(false) : setChanged(true);
}, [refreshValue]);
function onSubmit() {
var body = [
{ "op": "replace", "path": "/apiRefresh", "value": refreshValue }
@ -108,7 +111,7 @@ export default function UserSettings(props) {
</DialogContent>
<DialogActions>
<Button onClick={handleClose}>Cancel</Button>
<Button onClick={onSubmit} disabled={unchanged || sending}>
<Button onClick={onSubmit} disabled={!changed || sending}>
Apply
</Button>
</DialogActions>