diff --git a/.gitignore b/.gitignore index 66a0673f5..991371dfe 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ yarn-debug.log* yarn-error.log* # local env files +.env .env.local .env.development.local .env.test.local diff --git a/src/components/Dashboard/Views/DashboardView.tsx b/src/components/Dashboard/Views/DashboardView.tsx index 194098857..202232e45 100644 --- a/src/components/Dashboard/Views/DashboardView.tsx +++ b/src/components/Dashboard/Views/DashboardView.tsx @@ -60,7 +60,7 @@ const usePrepareGridstack = () => { }, [width]); return { - isReady: !!mainAreaWidth, + isReady: Boolean(mainAreaWidth), mainAreaRef, }; }; diff --git a/src/hooks/widgets/dashDot/api.ts b/src/hooks/widgets/dashDot/api.ts index eafb8b25c..36c82a55e 100644 --- a/src/hooks/widgets/dashDot/api.ts +++ b/src/hooks/widgets/dashDot/api.ts @@ -29,7 +29,7 @@ export const useGetUsenetInfo = (params: UsenetInfoRequestParams) => refetchInterval: POLLING_INTERVAL, keepPreviousData: true, retry: 2, - enabled: !!params.appId, + enabled: Boolean(params.appId), } ); diff --git a/src/hooks/widgets/rss/useGetRssFeed.tsx b/src/hooks/widgets/rss/useGetRssFeed.tsx deleted file mode 100644 index d96176466..000000000 --- a/src/hooks/widgets/rss/useGetRssFeed.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { useQuery } from '@tanstack/react-query'; - -export const useGetRssFeed = (feedUrl: string, widgetId: string) => - useQuery({ - queryKey: ['rss-feed', feedUrl], - queryFn: async () => { - const response = await fetch(`/api/modules/rss?widgetId=${widgetId}`); - return response.json(); - }, - }); diff --git a/src/pages/api/docker/DockerSingleton.ts b/src/pages/api/docker/DockerSingleton.ts index 804444274..9694059be 100644 --- a/src/pages/api/docker/DockerSingleton.ts +++ b/src/pages/api/docker/DockerSingleton.ts @@ -9,7 +9,12 @@ export default class DockerSingleton extends Docker { public static getInstance(): DockerSingleton { if (!DockerSingleton.dockerInstance) { - DockerSingleton.dockerInstance = new DockerSingleton(); + DockerSingleton.dockerInstance = new Docker({ + // If env variable DOCKER_HOST is not set, it will use the default socket + ...(process.env.DOCKER_HOST && { host: process.env.DOCKER_HOST }), + // Same thing for docker port + ...(process.env.DOCKER_PORT && { port: process.env.DOCKER_PORT }), + }); } return DockerSingleton.dockerInstance; } diff --git a/src/widgets/rss/RssWidgetTile.tsx b/src/widgets/rss/RssWidgetTile.tsx index 095d58771..7eba78e37 100644 --- a/src/widgets/rss/RssWidgetTile.tsx +++ b/src/widgets/rss/RssWidgetTile.tsx @@ -14,7 +14,6 @@ import { Stack, Text, Title, - UnstyledButton, } from '@mantine/core'; import { IconBulldozer, @@ -25,11 +24,11 @@ import { IconRss, IconSpeakerphone, } from '@tabler/icons'; +import { useQuery } from '@tanstack/react-query'; +import dayjs from 'dayjs'; import { useTranslation } from 'next-i18next'; import Link from 'next/link'; import { useState } from 'react'; -import { useGetRssFeed } from '../../hooks/widgets/rss/useGetRssFeed'; -import { sleep } from '../../tools/client/time'; import { defineWidget } from '../helper'; import { IWidget } from '../widgets'; @@ -57,6 +56,15 @@ interface RssTileProps { widget: IRssWidget; } +const useGetRssFeed = (feedUrl: string) => + useQuery({ + queryKey: ['rss-feed', feedUrl], + queryFn: async () => { + const response = await fetch('/api/modules/rss'); + return response.json(); + }, + }); + function RssTile({ widget }: RssTileProps) { const { t } = useTranslation('modules/rss'); const { data, isLoading, isFetching, isError, refetch } = useGetRssFeed( @@ -66,9 +74,21 @@ function RssTile({ widget }: RssTileProps) { const { classes } = useStyles(); const [loadingOverlayVisible, setLoadingOverlayVisible] = useState(false); + function formatDate(input: string): string { + // Parse the input date as a local date + const inputDate = dayjs(new Date(input)); + const now = dayjs(); // Current date and time + + // The difference between the input date and now + const difference = now.diff(inputDate, 'ms'); + const duration = dayjs.duration(difference, 'ms'); + const humanizedDuration = duration.humanize(); + return `${humanizedDuration} ago`; + } + if (!data || isLoading) { return ( -