mirror of
https://github.com/samanhappy/mcphub.git
synced 2025-12-24 02:39:19 -05:00
20 lines
621 B
TypeScript
20 lines
621 B
TypeScript
// This hook now delegates to the ServerContext to avoid duplicate requests
|
|
// All components will share the same server data and polling mechanism
|
|
import { useServerContext } from '@/contexts/ServerContext';
|
|
import { useEffect } from 'react';
|
|
|
|
export const useServerData = (options?: { refreshOnMount?: boolean }) => {
|
|
const context = useServerContext();
|
|
const { refreshIfNeeded } = context;
|
|
|
|
// Optionally refresh on mount for pages that need fresh data
|
|
useEffect(() => {
|
|
if (options?.refreshOnMount) {
|
|
refreshIfNeeded();
|
|
}
|
|
}, [options?.refreshOnMount, refreshIfNeeded]);
|
|
|
|
return context;
|
|
};
|
|
|