-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathRefetchIntervals.tsx
51 lines (47 loc) · 1.44 KB
/
RefetchIntervals.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use client';
import { revalidateTKOalyEvents } from '@/server/TKOalyEvents';
import { revalidateIlotaloEvents } from '@/server/ilotaloEvents';
import { revalidateLectures } from '@/server/lectures';
import { revalidatePohinaFactor } from '@/server/pohinaFactor';
import { revalidateRestaurants } from '@/server/restaurants';
import { revalidateTransit } from '@/server/transit';
import { useEffect } from 'react';
// This file contains intervals for updating all the slides
export const RefetchIntervals = () => {
useEffect(() => {
// Intervals for revalidating slide data
const TKOalyEventsInterval = setInterval(
() => void revalidateTKOalyEvents(),
5 * 60 * 1000
);
const ilotaloEventsInterval = setInterval(
() => void revalidateIlotaloEvents(),
15 * 60 * 1000
);
const pohinaFactorInterval = setInterval(
() => void revalidatePohinaFactor(),
5 * 60 * 1000
);
const restaurantsInterval = setInterval(
() => void revalidateRestaurants(),
60 * 60 * 1000
);
const lecturesInterval = setInterval(
() => void revalidateLectures(),
60 * 60 * 1000
);
const transitInterval = setInterval(
() => void revalidateTransit(),
5 * 1000
);
return () => {
clearInterval(TKOalyEventsInterval);
clearInterval(ilotaloEventsInterval);
clearInterval(pohinaFactorInterval);
clearInterval(restaurantsInterval);
clearInterval(lecturesInterval);
clearInterval(transitInterval);
};
}, []);
return null;
};