From 5b67f27345ae71298016f9788a9b9203d2a807fd Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:55:45 +0530 Subject: [PATCH] fix: remove get requests from the catch block (#3135) * fix: refetching project filters on error * fix: get request in the catch block --- web/constants/swr-config.ts | 5 +++++ web/lib/app-provider.tsx | 5 ++++- web/store/issues/project-issues/cycle/filter.store.ts | 4 ++-- web/store/issues/project-issues/module/filter.store.ts | 4 ++-- web/store/issues/project-issues/project-view/filter.store.ts | 4 ++-- 5 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 web/constants/swr-config.ts diff --git a/web/constants/swr-config.ts b/web/constants/swr-config.ts new file mode 100644 index 000000000..063d5db54 --- /dev/null +++ b/web/constants/swr-config.ts @@ -0,0 +1,5 @@ +export const SWR_CONFIG = { + refreshWhenHidden: false, + revalidateIfStale: false, + errorRetryCount: 3, +}; diff --git a/web/lib/app-provider.tsx b/web/lib/app-provider.tsx index ba882f174..e9fd27e0a 100644 --- a/web/lib/app-provider.tsx +++ b/web/lib/app-provider.tsx @@ -12,6 +12,9 @@ import { THEMES } from "constants/themes"; import InstanceLayout from "layouts/instance-layout"; // contexts import { ToastContextProvider } from "contexts/toast.context"; +import { SWRConfig } from "swr"; +// constants +import { SWR_CONFIG } from "constants/swr-config"; // dynamic imports const StoreWrapper = dynamic(() => import("lib/wrappers/store-wrapper"), { ssr: false }); const PosthogWrapper = dynamic(() => import("lib/wrappers/posthog-wrapper"), { ssr: false }); @@ -48,7 +51,7 @@ export const AppProvider: FC = observer((props) => { posthogAPIKey={envConfig?.posthog_api_key || null} posthogHost={envConfig?.posthog_host || null} > - {children} + {children} diff --git a/web/store/issues/project-issues/cycle/filter.store.ts b/web/store/issues/project-issues/cycle/filter.store.ts index b78999d7e..bd7a76ce1 100644 --- a/web/store/issues/project-issues/cycle/filter.store.ts +++ b/web/store/issues/project-issues/cycle/filter.store.ts @@ -170,7 +170,7 @@ export class CycleIssuesFilterStore extends IssueFilterBaseStore implements ICyc return filters; } catch (error) { - this.fetchFilters(workspaceSlug, projectId, cycleId); + console.log("error in fetchCycleFilters", error); throw error; } }; @@ -215,7 +215,7 @@ export class CycleIssuesFilterStore extends IssueFilterBaseStore implements ICyc await this.fetchCycleFilters(workspaceSlug, projectId, cycleId); return; } catch (error) { - this.fetchFilters(workspaceSlug, projectId, cycleId); + console.log("error in cycleFetchFilters", error); throw error; } }; diff --git a/web/store/issues/project-issues/module/filter.store.ts b/web/store/issues/project-issues/module/filter.store.ts index 103528ba8..7f75cdd78 100644 --- a/web/store/issues/project-issues/module/filter.store.ts +++ b/web/store/issues/project-issues/module/filter.store.ts @@ -170,7 +170,7 @@ export class ModuleIssuesFilterStore extends IssueFilterBaseStore implements IMo return filters; } catch (error) { - this.fetchFilters(workspaceSlug, projectId, moduleId); + console.log("error in moduleFetchFilters", error); throw error; } }; @@ -216,7 +216,7 @@ export class ModuleIssuesFilterStore extends IssueFilterBaseStore implements IMo await this.fetchModuleFilters(workspaceSlug, projectId, moduleId); return; } catch (error) { - this.fetchFilters(workspaceSlug, projectId, moduleId); + console.log("error in projectFetchFilters", error); throw error; } }; diff --git a/web/store/issues/project-issues/project-view/filter.store.ts b/web/store/issues/project-issues/project-view/filter.store.ts index 215e3749f..e6c97809b 100644 --- a/web/store/issues/project-issues/project-view/filter.store.ts +++ b/web/store/issues/project-issues/project-view/filter.store.ts @@ -170,7 +170,7 @@ export class ViewIssuesFilterStore extends IssueFilterBaseStore implements IView return filters; } catch (error) { - this.fetchFilters(workspaceSlug, projectId, viewId); + console.log("error in viewFetchFilters", error); throw error; } }; @@ -216,7 +216,7 @@ export class ViewIssuesFilterStore extends IssueFilterBaseStore implements IView await this.fetchViewFilters(workspaceSlug, projectId, viewId); return; } catch (error) { - this.fetchFilters(workspaceSlug, projectId, viewId); + console.log("error in viewFetchFilters", error); throw error; } };