Fix Admin test upload API endpoint URL & fix AI coach infinite reload caused by session polling
This commit is contained in:
@@ -41,8 +41,8 @@ export function useActiveUser() {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const fetchUserProfile = useCallback(async (id: string) => {
|
||||
setLoading(true);
|
||||
const fetchUserProfile = useCallback(async (id: string, isPoll: boolean = false) => {
|
||||
if (!isPoll) setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const res = await fetch(`/api/users/${id}`);
|
||||
@@ -71,7 +71,7 @@ export function useActiveUser() {
|
||||
console.error("Error fetching active user profile:", err);
|
||||
setError(err.message || "Failed to load user");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
if (!isPoll) setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -90,7 +90,7 @@ export function useActiveUser() {
|
||||
|
||||
// Poll every 10 seconds for session validity
|
||||
const interval = setInterval(() => {
|
||||
fetchUserProfile(userId);
|
||||
fetchUserProfile(userId, true);
|
||||
}, 10000);
|
||||
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user