Added debounce to Share file fields (#3388)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -40,6 +40,7 @@ import { api } from "api";
|
|||||||
import { errorToHandler } from "api/errors";
|
import { errorToHandler } from "api/errors";
|
||||||
import { getMaxShareLinkExpTime } from "screens/Console/ObjectBrowser/objectBrowserThunks";
|
import { getMaxShareLinkExpTime } from "screens/Console/ObjectBrowser/objectBrowserThunks";
|
||||||
import { maxShareLinkExpTime } from "screens/Console/ObjectBrowser/objectBrowserSlice";
|
import { maxShareLinkExpTime } from "screens/Console/ObjectBrowser/objectBrowserSlice";
|
||||||
|
import debounce from "lodash/debounce";
|
||||||
|
|
||||||
interface IShareFileProps {
|
interface IShareFileProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -64,7 +65,7 @@ const ShareFile = ({
|
|||||||
const [dateValid, setDateValid] = useState<boolean>(true);
|
const [dateValid, setDateValid] = useState<boolean>(true);
|
||||||
const [versionID, setVersionID] = useState<string>("null");
|
const [versionID, setVersionID] = useState<string>("null");
|
||||||
|
|
||||||
const dateChanged = (newDate: string, isValid: boolean) => {
|
const debouncedDateChange = debounce((newDate: string, isValid: boolean) => {
|
||||||
setDateValid(isValid);
|
setDateValid(isValid);
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
setSelectedDate(newDate);
|
setSelectedDate(newDate);
|
||||||
@@ -72,7 +73,7 @@ const ShareFile = ({
|
|||||||
}
|
}
|
||||||
setSelectedDate("");
|
setSelectedDate("");
|
||||||
setShareURL("");
|
setShareURL("");
|
||||||
};
|
}, 300);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(getMaxShareLinkExpTime());
|
dispatch(getMaxShareLinkExpTime());
|
||||||
@@ -214,7 +215,7 @@ const ShareFile = ({
|
|||||||
id="date"
|
id="date"
|
||||||
label="Active for"
|
label="Active for"
|
||||||
maxSeconds={maxShareLinkExpTimeVal}
|
maxSeconds={maxShareLinkExpTimeVal}
|
||||||
onChange={dateChanged}
|
onChange={debouncedDateChange}
|
||||||
entity="Link"
|
entity="Link"
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
Reference in New Issue
Block a user