refactor(usage): consolidate query logic to eliminate DRY violations
Breaking Changes: - Removed useAutoUsageQuery hook (119 lines) - Unified all usage queries into single useUsageQuery hook Technical Improvements: - Eliminated duplicate state management (React Query + manual useState) - Fixed single source of truth principle violation - Replaced manual setInterval with React Query's built-in refetchInterval - Reduced UsageFooter complexity by 28% (54 → 39 lines) New Features: - useUsageQuery now accepts autoQueryInterval option - Automatic query interval control (0 = disabled, min 1 minute) - Built-in lastQueriedAt timestamp from dataUpdatedAt - Auto-query only enabled for currently active provider Architecture Benefits: - Single data source: manual and auto queries share same cache - No more state inconsistency between manual/auto query results - Leverages React Query's caching, deduplication, and background updates - Cleaner separation of concerns Code Changes: - src/lib/query/queries.ts: Enhanced useUsageQuery with auto-query support - src/components/UsageFooter.tsx: Simplified to use single query hook - src/hooks/useAutoUsageQuery.ts: Deleted (redundant) - All type checks passed
This commit is contained in:
@@ -539,8 +539,8 @@ pub fn run() {
|
||||
commands::delete_claude_mcp_server,
|
||||
commands::validate_mcp_command,
|
||||
// usage query
|
||||
commands::query_provider_usage,
|
||||
commands::test_usage_script,
|
||||
commands::queryProviderUsage,
|
||||
commands::testUsageScript,
|
||||
// New MCP via config.json (SSOT)
|
||||
commands::get_mcp_config,
|
||||
commands::upsert_mcp_server_in_config,
|
||||
|
||||
Reference in New Issue
Block a user