Add global refresh interval for all SWR calls
This commit is contained in:
parent
0e1e2bde22
commit
9995f2ab6c
6 changed files with 10 additions and 13 deletions
|
@ -11,8 +11,9 @@ function Widget({ options }) {
|
|||
const { t, i18n } = useTranslation();
|
||||
|
||||
const { data, error } = useSWR(
|
||||
`/api/widgets/openweathermap?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`
|
||||
);
|
||||
`/api/widgets/openweathermap?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`, {
|
||||
refreshInterval: null
|
||||
});
|
||||
|
||||
if (error || data?.cod === 401 || data?.error) {
|
||||
return (
|
||||
|
|
|
@ -8,9 +8,7 @@ import UsageBar from "./usage-bar";
|
|||
export default function Cpu({ expanded }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { data, error } = useSWR(`/api/widgets/resources?type=cpu`, {
|
||||
refreshInterval: 1500,
|
||||
});
|
||||
const { data, error } = useSWR(`/api/widgets/resources?type=cpu`);
|
||||
|
||||
if (error || data?.error) {
|
||||
return (
|
||||
|
|
|
@ -8,9 +8,7 @@ import UsageBar from "./usage-bar";
|
|||
export default function Disk({ options, expanded }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { data, error } = useSWR(`/api/widgets/resources?type=disk&target=${options.disk}`, {
|
||||
refreshInterval: 1500,
|
||||
});
|
||||
const { data, error } = useSWR(`/api/widgets/resources?type=disk&target=${options.disk}`);
|
||||
|
||||
if (error || data?.error) {
|
||||
return (
|
||||
|
|
|
@ -8,9 +8,7 @@ import UsageBar from "./usage-bar";
|
|||
export default function Memory({ expanded }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { data, error } = useSWR(`/api/widgets/resources?type=memory`, {
|
||||
refreshInterval: 1500,
|
||||
});
|
||||
const { data, error } = useSWR(`/api/widgets/resources?type=memory`);
|
||||
|
||||
if (error || data?.error) {
|
||||
return (
|
||||
|
|
|
@ -11,8 +11,9 @@ function Widget({ options }) {
|
|||
const { t, i18n } = useTranslation();
|
||||
|
||||
const { data, error } = useSWR(
|
||||
`/api/widgets/weather?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`
|
||||
);
|
||||
`/api/widgets/weather?${new URLSearchParams({ lang: i18n.language, ...options }).toString()}`, {
|
||||
refreshInterval: null
|
||||
});
|
||||
|
||||
if (error || data?.error) {
|
||||
return (
|
||||
|
|
|
@ -14,6 +14,7 @@ function MyApp({ Component, pageProps }) {
|
|||
return (
|
||||
<SWRConfig
|
||||
value={{
|
||||
refreshInterval: 1500,
|
||||
fetcher: (resource, init) => fetch(resource, init).then((res) => res.json()),
|
||||
}}
|
||||
>
|
||||
|
|
Loading…
Add table
Reference in a new issue