1
0
mirror of https://github.com/pavlobu/deskreen.git synced 2025-06-01 23:30:09 -07:00
deskreen/app/client/src/containers/MainView/handleDisplayingLoadingSharingIconLoop.ts
2020-12-25 01:11:01 +02:00

38 lines
1.0 KiB
TypeScript

export default (
params: handleDisplayingLoadingSharingIconLoopParams
) => {
const {
promptStep,
url,
setIsShownLoadingSharingIcon,
loadingSharingIconType,
isShownLoadingSharingIcon,
setLoadingSharingIconType,
} = params;
return () => {
let interval: NodeJS.Timeout;
if (promptStep === 3 && url === undefined) {
setIsShownLoadingSharingIcon(true);
let currentIcon = loadingSharingIconType;
let isShownIcon = isShownLoadingSharingIcon;
let isShownWithFadingUIEffect = false;
interval = setInterval(() => {
isShownIcon = !isShownIcon;
setIsShownLoadingSharingIcon(isShownIcon);
if (isShownWithFadingUIEffect) {
currentIcon = currentIcon === 'desktop' ? 'application' : 'desktop';
setLoadingSharingIconType(currentIcon);
isShownWithFadingUIEffect = false;
} else {
isShownWithFadingUIEffect = true;
}
}, 1500);
}
return () => {
clearInterval(interval);
};
};
};