feat(donate): force refresh button
This commit is contained in:
@@ -18,6 +18,12 @@ export async function testPopup() {
|
||||
});
|
||||
}
|
||||
|
||||
export async function reloadWidget() {
|
||||
if (!(await adminCheck())) throw new Error("Unauthorized");
|
||||
|
||||
sse.donate.pub("refresh", null);
|
||||
}
|
||||
|
||||
export async function resendPopup(id: string) {
|
||||
if (!(await adminCheck())) throw new Error("Unauthorized");
|
||||
const [sub] = await db
|
||||
|
||||
@@ -10,10 +10,16 @@ import {
|
||||
import { donations } from "@/lib/db/schema";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { BitcoinIcon, BugPlay, Copy, MessageCircleWarning } from "lucide-react";
|
||||
import {
|
||||
BitcoinIcon,
|
||||
BugPlay,
|
||||
ChevronsLeftRightEllipsis,
|
||||
Copy,
|
||||
MessageCircleWarning,
|
||||
} from "lucide-react";
|
||||
import { useEllipsisVisible } from "react-hook-text-overflow";
|
||||
import { ActionButton } from "../../../../components/action-button";
|
||||
import { resendPopup, testPopup } from "./api";
|
||||
import { reloadWidget, resendPopup, testPopup } from "./api";
|
||||
import { useEffect } from "react";
|
||||
import { sse } from "@/lib/db/sse-endpoints";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -57,11 +63,22 @@ const columns: ColumnDef<typeof donations.$inferSelect>[] = [
|
||||
accessorKey: "id",
|
||||
header() {
|
||||
return (
|
||||
<SimpleTooltip text="Send test popup">
|
||||
<ActionButton variant="outline" size="icon-sm" action={testPopup}>
|
||||
<BugPlay />
|
||||
</ActionButton>
|
||||
</SimpleTooltip>
|
||||
<div className="flex gap-1">
|
||||
<SimpleTooltip text="Send test popup">
|
||||
<ActionButton variant="outline" size="icon-sm" action={testPopup}>
|
||||
<BugPlay />
|
||||
</ActionButton>
|
||||
</SimpleTooltip>
|
||||
<SimpleTooltip text="Reload all widget">
|
||||
<ActionButton
|
||||
variant="outline"
|
||||
size="icon-sm"
|
||||
action={reloadWidget}
|
||||
>
|
||||
<ChevronsLeftRightEllipsis />
|
||||
</ActionButton>
|
||||
</SimpleTooltip>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
cell(row) {
|
||||
|
||||
@@ -75,6 +75,7 @@ export default function () {
|
||||
const { clean } = sse.donate.subMany({
|
||||
heartbeat: (tag) => pendingHeartbeat[tag]?.(),
|
||||
ping: enqueue,
|
||||
refresh: () => location.reload(),
|
||||
});
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
|
||||
@@ -42,6 +42,7 @@ export const sse = sseEndpointMap({
|
||||
// roundtrip SSE system check
|
||||
heartbeat: z.number(),
|
||||
update: z.null(),
|
||||
refresh: z.null(),
|
||||
},
|
||||
// Passive Update Checker
|
||||
active: {
|
||||
|
||||
Reference in New Issue
Block a user