Skip to content

Commit

Permalink
update swr config to not fetch everything on focus (#3350)
Browse files Browse the repository at this point in the history
Co-authored-by: Rahul R <rahulr@Rahuls-MacBook-Pro.local>
  • Loading branch information
rahulramesha and Rahul R committed Jan 11, 2024
1 parent ece4d5b commit 3c9926d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
20 changes: 6 additions & 14 deletions web/components/issues/issue-layouts/roots/project-layout-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,12 @@ export const ProjectLayoutRoot: FC = observer(() => {
// hooks
const { issues, issuesFilter } = useIssues(EIssuesStoreType.PROJECT);

const {} = useSWR(
workspaceSlug && projectId ? `PROJECT_ISSUES_${workspaceSlug}_${projectId}` : null,
async () => {
if (workspaceSlug && projectId) {
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString());
await issues?.fetchIssues(
workspaceSlug.toString(),
projectId.toString(),
issues?.groupedIssueIds ? "mutation" : "init-loader"
);
}
},
{ revalidateOnFocus: false, refreshInterval: 600000, revalidateOnMount: true }
);
useSWR(workspaceSlug && projectId ? `PROJECT_ISSUES_${workspaceSlug}_${projectId}` : null, async () => {
if (workspaceSlug && projectId) {
await issuesFilter?.fetchFilters(workspaceSlug.toString(), projectId.toString());
await issues?.fetchIssues(workspaceSlug.toString(), projectId.toString(), issues?.groupedIssueIds ? "mutation" : "init-loader");
}
});

const activeLayout = issuesFilter?.issueFilters?.displayFilters?.layout;

Expand Down
3 changes: 3 additions & 0 deletions web/constants/swr-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export const SWR_CONFIG = {
refreshWhenHidden: false,
revalidateIfStale: false,
revalidateOnFocus: false,
revalidateOnMount: true,
refreshInterval: 600000,
errorRetryCount: 3,
};

0 comments on commit 3c9926d

Please sign in to comment.