fix: unnecesary requests

This commit is contained in:
Ephraim Atta-Duncan
2024-04-05 12:02:05 +00:00
parent 81ab220f1e
commit ea64ccae29
2 changed files with 9 additions and 18 deletions

View File

@ -13,20 +13,9 @@ export function StatusWidgetContainer() {
function StatusWidgetFallback() {
return (
<a
className="border-border inline-flex max-w-fit items-center justify-between gap-2 space-x-2 rounded-md border border-gray-200 px-3 py-1 text-sm"
href="https://status.documenso.com"
target="_blank"
rel="noreferrer"
>
<div>
<p className="text-sm">Operational</p>
</div>
<span className="relative ml-auto flex h-1.5 w-1.5">
<span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75" />
<span className="relative inline-flex h-1.5 w-1.5 rounded-full bg-green-500" />
</span>
</a>
<div className="border-border inline-flex max-w-fit items-center justify-between space-x-2 rounded-md border border-gray-200 px-2 py-2 pr-3 text-sm">
<span className="bg-muted h-2 w-36 animate-pulse rounded-md" />
<span className="bg-muted relative inline-flex h-2 w-2 rounded-full" />
</div>
);
}

View File

@ -1,6 +1,7 @@
import { use } from 'react';
import { use, useMemo } from 'react';
import { type Status, getStatus } from '@openstatus/react';
import type { Status } from '@openstatus/react';
import { getStatus } from '@openstatus/react';
import { cn } from '@documenso/ui/lib/utils';
@ -45,7 +46,8 @@ const getStatusLevel = (level: Status) => {
};
export function StatusWidget() {
const { status } = use(getStatus('documenso-status'));
const getStatusMemoized = useMemo(async () => getStatus('documenso-status'), []);
const { status } = use(getStatusMemoized);
const level = getStatusLevel(status);
return (