fix: increase rate limit to 1000/15min, add WatchHistory error handling
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { Clock, Egg, Film, Tv } from "lucide-react";
|
||||
import { AlertTriangle, Clock, Egg, Film, Tv } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { userApi } from "@/lib/api";
|
||||
import { formatNumber } from "@/lib/utils";
|
||||
@@ -8,11 +8,22 @@ import { formatNumber } from "@/lib/utils";
|
||||
export function WatchHistory() {
|
||||
const [events, setEvents] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
userApi
|
||||
.getWatchHistory(1, 50)
|
||||
.then((r) => setEvents(r.data.events || []))
|
||||
.then((r) => {
|
||||
setEvents(r.data.events || []);
|
||||
setError(null);
|
||||
})
|
||||
.catch((err) => {
|
||||
setError(
|
||||
err?.response?.status === 429
|
||||
? "Slow down, chicken!"
|
||||
: "Failed to load history",
|
||||
);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
@@ -20,6 +31,17 @@ export function WatchHistory() {
|
||||
return (
|
||||
<div className="p-4 font-bold animate-pulse">Peeking at history...</div>
|
||||
);
|
||||
|
||||
if (error)
|
||||
return (
|
||||
<div className="text-center py-10">
|
||||
<div className="text-5xl mb-4">🐔</div>
|
||||
<div className="font-black uppercase tracking-widest text-sm text-destructive flex items-center justify-center gap-2">
|
||||
<AlertTriangle className="h-4 w-4" /> {error}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
if (events.length === 0)
|
||||
return (
|
||||
<div className="text-center py-10 opacity-40">
|
||||
|
||||
Reference in New Issue
Block a user