Skip to content

Commit 6908231

Browse files
committed
feat: reduce server requests
1 parent 94064df commit 6908231

File tree

14 files changed

+129
-11
lines changed

14 files changed

+129
-11
lines changed

apps/frontend/src/components/autopost/autopost.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,14 @@ export const AddOrEditWebhook: FC<{
228228
},
229229
[]
230230
);
231-
const { data: dataList, isLoading } = useSWR('integrations', integration);
231+
const { data: dataList, isLoading } = useSWR('integrations', integration, {
232+
revalidateOnFocus: false,
233+
revalidateOnReconnect: false,
234+
revalidateIfStale: false,
235+
revalidateOnMount: true,
236+
refreshWhenHidden: false,
237+
refreshWhenOffline: false,
238+
});
232239
const callBack = useCallback(
233240
async (values: any) => {
234241
await fetch(data?.id ? `/autopost/${data?.id}` : '/autopost', {

apps/frontend/src/components/launches/calendar.context.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,22 @@ export const CalendarWeekProvider: FC<{
176176
return (await fetch('/sets')).json();
177177
}, []);
178178

179-
const { data: sets, mutate } = useSWR('sets', setList);
180-
const { data: sign } = useSWR('default-sign', defaultSign);
179+
const { data: sets, mutate } = useSWR('sets', setList, {
180+
revalidateOnFocus: false,
181+
revalidateOnReconnect: false,
182+
revalidateIfStale: false,
183+
revalidateOnMount: true,
184+
refreshWhenHidden: false,
185+
refreshWhenOffline: false,
186+
});
187+
const { data: sign } = useSWR('default-sign', defaultSign, {
188+
revalidateOnFocus: false,
189+
revalidateOnReconnect: false,
190+
revalidateIfStale: false,
191+
revalidateOnMount: true,
192+
refreshWhenHidden: false,
193+
refreshWhenOffline: false,
194+
});
181195

182196
const setFiltersWrapper = useCallback(
183197
(filters: {

apps/frontend/src/components/launches/helpers/use.integration.list.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export const useIntegrationList = () => {
1212
}, []);
1313

1414
return useSWR('/integrations/list', load, {
15+
revalidateOnFocus: false,
16+
revalidateOnReconnect: false,
17+
revalidateIfStale: false,
18+
revalidateOnMount: true,
19+
refreshWhenHidden: false,
20+
refreshWhenOffline: false,
1521
fallbackData: [],
1622
});
1723
};

apps/frontend/src/components/launches/tags.component.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ export const TagsComponent: FC<{
3232
name: string;
3333
color: string;
3434
}[];
35-
}>('tags', loadTags);
35+
}>('tags', loadTags, {
36+
revalidateOnFocus: false,
37+
revalidateOnReconnect: false,
38+
revalidateIfStale: false,
39+
revalidateOnMount: true,
40+
refreshWhenHidden: false,
41+
refreshWhenOffline: false,
42+
});
3643
const onDelete = useCallback(
3744
(tagIndex: number) => {
3845
const modify = tagValue.filter((_, i) => i !== tagIndex);

apps/frontend/src/components/layout/continue.provider.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ export const ContinueProvider: FC = () => {
2222
return list;
2323
}, []);
2424
const { data: integrations } = useSWR('/integrations/list', load, {
25+
revalidateOnFocus: false,
26+
revalidateOnReconnect: false,
27+
revalidateIfStale: false,
28+
revalidateOnMount: true,
29+
refreshWhenHidden: false,
30+
refreshWhenOffline: false,
2531
fallbackData: [],
2632
});
2733
const closeModal = useCallback(() => {

apps/frontend/src/components/onboarding/connect.channels.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ export const ConnectChannels: FC = () => {
160160
}, []);
161161

162162
const { data: integrations, mutate } = useSWR('/integrations/list', load, {
163+
revalidateOnFocus: false,
164+
revalidateOnReconnect: false,
165+
revalidateIfStale: false,
166+
revalidateOnMount: true,
167+
refreshWhenHidden: false,
168+
refreshWhenOffline: false,
163169
fallbackData: [],
164170
});
165171

@@ -223,7 +229,10 @@ export const ConnectChannels: FC = () => {
223229
<div className="absolute w-full h-full top-0 start-0 z-[400]">
224230
<div className="absolute w-full h-full bg-primary/80 start-0 top-0 z-[200] p-[50px] flex justify-center">
225231
<div className="w-[400px]">
226-
<ModalWrapperComponent title="" customClose={() => setShowCustom(undefined)}>
232+
<ModalWrapperComponent
233+
title=""
234+
customClose={() => setShowCustom(undefined)}
235+
>
227236
{showCustom}
228237
</ModalWrapperComponent>
229238
</div>

apps/frontend/src/components/platform-analytics/platform.analytics.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ export const PlatformAnalytics = () => {
5151
return int.filter((f: any) => allowedIntegrations.includes(f.identifier));
5252
}, []);
5353
const { data, isLoading } = useSWR('analytics-list', load, {
54+
revalidateOnFocus: false,
55+
revalidateOnReconnect: false,
56+
revalidateIfStale: false,
57+
revalidateOnMount: true,
58+
refreshWhenHidden: false,
59+
refreshWhenOffline: false,
5460
fallbackData: [],
5561
});
5662
const sortedIntegrations = useMemo(() => {

apps/frontend/src/components/plugs/plugs.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,21 @@ export const Plugs = () => {
3434
load2,
3535
{
3636
fallbackData: [],
37+
revalidateOnFocus: false,
38+
revalidateOnReconnect: false,
39+
revalidateIfStale: false,
40+
revalidateOnMount: true,
41+
refreshWhenHidden: false,
42+
refreshWhenOffline: false,
3743
}
3844
);
3945
const { data, isLoading } = useSWR('analytics-list', load, {
46+
revalidateOnFocus: false,
47+
revalidateOnReconnect: false,
48+
revalidateIfStale: false,
49+
revalidateOnMount: true,
50+
refreshWhenHidden: false,
51+
refreshWhenOffline: false,
4052
fallbackData: [],
4153
});
4254

apps/frontend/src/components/sets/sets.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,27 @@ export const Sets: FC = () => {
6868
}, []);
6969

7070
const { isLoading, data: integrations } = useSWR('/integrations/list', load, {
71+
revalidateOnFocus: false,
72+
revalidateOnReconnect: false,
73+
revalidateIfStale: false,
74+
revalidateOnMount: true,
75+
refreshWhenHidden: false,
76+
refreshWhenOffline: false,
7177
fallbackData: [],
7278
});
7379

7480
const list = useCallback(async () => {
7581
return (await fetch('/sets')).json();
7682
}, []);
7783

78-
const { data, mutate } = useSWR('sets', list);
84+
const { data, mutate } = useSWR('sets', list, {
85+
revalidateOnFocus: false,
86+
revalidateOnReconnect: false,
87+
revalidateIfStale: false,
88+
revalidateOnMount: true,
89+
refreshWhenHidden: false,
90+
refreshWhenOffline: false,
91+
});
7992

8093
const addSet = useCallback(
8194
(params?: { id?: string; name?: string; content?: string }) => () => {

apps/frontend/src/components/standalone-modal/standalone.modal.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ export const StandaloneModal: FC = () => {
2727
data: integrations,
2828
mutate,
2929
} = useSWR('/integrations/list', load, {
30+
revalidateOnFocus: false,
31+
revalidateOnReconnect: false,
32+
revalidateIfStale: false,
33+
revalidateOnMount: true,
34+
refreshWhenHidden: false,
35+
refreshWhenOffline: false,
3036
fallbackData: [],
3137
});
3238
const { isLoading: isLoading2, data } = useSWR('/posts/find-slot', loadDate, {

0 commit comments

Comments
 (0)