Skip to content

Commit

Permalink
feat: skip changes checking if last task is not finish (#8086)
Browse files Browse the repository at this point in the history
  • Loading branch information
CurryYangxx authored Oct 16, 2024
1 parent c08d5de commit b7c9152
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IconName, IconProp } from '@fortawesome/fontawesome-svg-core';
import React, { type FC, useEffect, useState } from 'react';
import React, { type FC, useEffect, useRef, useState } from 'react';
import { Button, Collection, Menu, MenuItem, MenuTrigger, Popover, Section, Tooltip, TooltipTrigger } from 'react-aria-components';
import { useFetcher, useParams, useRevalidator } from 'react-router-dom';
import { useInterval } from 'react-use';
Expand Down Expand Up @@ -48,6 +48,8 @@ export const GitSyncDropdown: FC<Props> = ({ gitRepository, isInsomniaSyncEnable
const gitFetchFetcher = useFetcher<GitFetchLoaderData>();
const gitStatusFetcher = useFetcher<GitStatusResult>();

const isCheckingGitChanges = useRef(false);

const loadingPush = gitPushFetcher.state === 'loading';
const loadingPull = gitPullFetcher.state === 'loading';
const loadingFetch = gitFetchFetcher.state === 'loading';
Expand Down Expand Up @@ -83,10 +85,13 @@ export const GitSyncDropdown: FC<Props> = ({ gitRepository, isInsomniaSyncEnable
}
}, [gitStatusFetcher, organizationId, projectId, shouldFetchGitRepoStatus, workspaceId]);

useInterval(() => {
requestIdleCallback(() => {
checkGitChanges(workspaceId);
});
useInterval(async () => {
if (isCheckingGitChanges.current) {
return;
}
isCheckingGitChanges.current = true;
await checkGitChanges(workspaceId);
isCheckingGitChanges.current = false;
}, 30 * 1000);

useEffect(() => {
Expand Down

0 comments on commit b7c9152

Please sign in to comment.