Shared:Selectors:Files: add timer to showing list loader
This commit is contained in:
parent
888cbebce4
commit
1f36216278
@ -44,6 +44,7 @@ const useLoadersHelper = () => {
|
||||
const [isFirstLoad, setIsFirstLoad] = React.useState(true);
|
||||
|
||||
const startLoader = React.useRef<Date | null>(new Date());
|
||||
const loaderTimeout = React.useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
const breadCrumbsLoaderTimeout = React.useRef<NodeJS.Timeout | null>(null);
|
||||
const breadCrumbsStartLoader = React.useRef<Date | null>(new Date());
|
||||
@ -59,9 +60,10 @@ const useLoadersHelper = () => {
|
||||
|
||||
const calculateLoader = React.useCallback(() => {
|
||||
if (isFirstLoad) {
|
||||
setShowLoader(true);
|
||||
|
||||
startLoader.current = new Date();
|
||||
loaderTimeout.current = setTimeout(() => {
|
||||
startLoader.current = new Date();
|
||||
if (isMount.current) setShowLoader(true);
|
||||
}, SHOW_LOADER_TIMER);
|
||||
} else if (startLoader.current) {
|
||||
const currentDate = new Date();
|
||||
|
||||
@ -80,6 +82,11 @@ const useLoadersHelper = () => {
|
||||
setShowLoader(false);
|
||||
}
|
||||
}, MIN_LOADER_TIMER - ms);
|
||||
|
||||
loaderTimeout.current = null;
|
||||
} else if (loaderTimeout.current) {
|
||||
clearTimeout(loaderTimeout.current);
|
||||
loaderTimeout.current = null;
|
||||
}
|
||||
}, [isFirstLoad]);
|
||||
|
||||
|
@ -238,7 +238,7 @@ const FilesSelectorComponent = ({
|
||||
setSelectedItemType(undefined);
|
||||
getRootData();
|
||||
} else {
|
||||
setItems([]);
|
||||
// setItems([]);
|
||||
|
||||
setBreadCrumbs((bc) => {
|
||||
const idx = bc.findIndex(
|
||||
@ -302,7 +302,7 @@ const FilesSelectorComponent = ({
|
||||
if (item.isFolder) {
|
||||
setIsFirstLoad(true);
|
||||
|
||||
setItems([]);
|
||||
// setItems([]);
|
||||
setBreadCrumbs((value) => [
|
||||
...value,
|
||||
{
|
||||
@ -506,7 +506,7 @@ const FilesSelectorComponent = ({
|
||||
submitButtonLabel,
|
||||
submitButtonId,
|
||||
disableSubmitButton: getIsDisabled(
|
||||
isFirstLoad,
|
||||
isFirstLoad && showLoader,
|
||||
isSelectedParentFolder,
|
||||
selectedItemId,
|
||||
selectedItemType,
|
||||
|
Loading…
Reference in New Issue
Block a user