feat: add share page settings dialog + add org id to deployment as well
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
"use client";
|
||||
|
||||
import { LoadingIcon } from "@/components/LoadingIcon";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { RefreshCcw } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useTransition } from "react";
|
||||
|
||||
export function RouteRefresher(props: { interval: number }) {
|
||||
export function RouteRefresher(props: {
|
||||
interval: number;
|
||||
autoRefresh: boolean;
|
||||
}) {
|
||||
const [isPending, startTransition] = useTransition();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (!props.autoRefresh) return;
|
||||
|
||||
let timeout: NodeJS.Timeout;
|
||||
|
||||
const refresh = () => {
|
||||
@@ -35,7 +42,24 @@ export function RouteRefresher(props: { interval: number }) {
|
||||
clearTimeout(timeout);
|
||||
window.removeEventListener("visibilitychange", handleVisibilityChange);
|
||||
};
|
||||
}, [props.interval, router]);
|
||||
}, [props.interval, router, props.autoRefresh]);
|
||||
|
||||
return <div>{isPending && <LoadingIcon />}</div>;
|
||||
return (
|
||||
<div>
|
||||
{isPending && <LoadingIcon />}
|
||||
{!isPending && !props.autoRefresh && (
|
||||
<Button
|
||||
className="p-0 h-min"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
startTransition(() => {
|
||||
router.refresh();
|
||||
});
|
||||
}}
|
||||
>
|
||||
<RefreshCcw size={14} />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user