From 56ab09949918864e2b3ff6baf433ddbfc0c9a95b Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 28 Jul 2023 22:28:06 -0700 Subject: [PATCH] Should not check updates in cloud mode. Minor updates. --- components/common/UpdateNotice.js | 6 +++++- components/metrics/PageviewsChart.js | 3 +-- components/pages/realtime/RealtimePage.js | 4 +--- pages/api/websites/[id]/stats.ts | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/components/common/UpdateNotice.js b/components/common/UpdateNotice.js index 2cdbcb43..bef6be98 100644 --- a/components/common/UpdateNotice.js +++ b/components/common/UpdateNotice.js @@ -13,7 +13,11 @@ export function UpdateNotice({ user, config }) { const { pathname } = useRouter(); const [dismissed, setDismissed] = useState(checked); const allowUpdate = - user?.isAdmin && !config?.updatesDisabled && !pathname.includes('/share/') && !dismissed; + user?.isAdmin && + !config?.updatesDisabled && + !config?.cloudMode && + !pathname.includes('/share/') && + !dismissed; const updateCheck = useCallback(() => { setItem(VERSION_CHECK, { version: latest, time: Date.now() }); diff --git a/components/metrics/PageviewsChart.js b/components/metrics/PageviewsChart.js index 362c616e..1b481c48 100644 --- a/components/metrics/PageviewsChart.js +++ b/components/metrics/PageviewsChart.js @@ -3,7 +3,7 @@ import BarChart from './BarChart'; import { useLocale, useTheme, useMessages } from 'hooks'; import { renderDateLabels, renderStatusTooltipPopup } from 'lib/charts'; -export function PageviewsChart({ websiteId, data, unit, className, loading, ...props }) { +export function PageviewsChart({ websiteId, data, unit, loading, ...props }) { const { formatMessage, labels } = useMessages(); const { colors } = useTheme(); const { locale } = useLocale(); @@ -31,7 +31,6 @@ export function PageviewsChart({ websiteId, data, unit, className, loading, ...p -
- -
+ diff --git a/pages/api/websites/[id]/stats.ts b/pages/api/websites/[id]/stats.ts index 3e2b96a8..3164913d 100644 --- a/pages/api/websites/[id]/stats.ts +++ b/pages/api/websites/[id]/stats.ts @@ -1,4 +1,4 @@ -import { addMinutes, differenceInMinutes } from 'date-fns'; +import { subMinutes, differenceInMinutes } from 'date-fns'; import { NextApiResponse } from 'next'; import { methodNotAllowed, ok, unauthorized } from 'next-basics'; import { canViewWebsite } from 'lib/auth'; @@ -53,8 +53,8 @@ export default async ( const { startDate, endDate } = await parseDateRangeQuery(req); const diff = differenceInMinutes(endDate, startDate); - const prevStartDate = addMinutes(startDate, -diff); - const prevEndDate = addMinutes(endDate, -diff); + const prevStartDate = subMinutes(startDate, diff); + const prevEndDate = subMinutes(endDate, diff); const metrics = await getWebsiteStats(websiteId, { startDate,