fix(ui): restore saved states of quota override checkboxes (#1282)

* fix(ui): restore saved states of quota override checkboxes

* fix: check if value is undefined or null, not just truthy

Co-authored-by: sct <ryan@sct.dev>
pull/1288/head
TheCatLady 4 years ago committed by GitHub
parent 7230915094
commit 2059fc1cd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,7 +1,7 @@
import axios from 'axios';
import { Field, Form, Formik } from 'formik';
import { useRouter } from 'next/router';
import React, { useMemo, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { useToasts } from 'react-toast-notifications';
import useSWR from 'swr';
@ -57,6 +57,15 @@ const UserGeneralSettings: React.FC = () => {
user ? `/api/v1/user/${user?.id}/settings/main` : null
);
useEffect(() => {
setMovieQuotaEnabled(
data?.movieQuotaLimit != undefined && data?.movieQuotaDays != undefined
);
setTvQuotaEnabled(
data?.tvQuotaLimit != undefined && data?.tvQuotaDays != undefined
);
}, [data]);
const { data: languages, error: languagesError } = useSWR<Language[]>(
'/api/v1/languages'
);

Loading…
Cancel
Save