mirror of
https://github.com/lukaszraczylo/claude-mnemonic.git
synced 2026-06-13 02:06:24 +00:00
Display only current project statistics in statusline. (#3)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ref, onMounted, onUnmounted, watch } from 'vue'
|
||||
import { ref, onMounted, onUnmounted, watch, type Ref } from 'vue'
|
||||
import type { Stats } from '@/types'
|
||||
import { fetchStats } from '@/utils/api'
|
||||
import { useSSE } from './useSSE'
|
||||
@@ -6,7 +6,7 @@ import { useSSE } from './useSSE'
|
||||
// Fallback poll interval when SSE is disconnected
|
||||
const FALLBACK_POLL_INTERVAL = 10000 // 10 seconds
|
||||
|
||||
export function useStats() {
|
||||
export function useStats(projectRef?: Ref<string | null>) {
|
||||
const stats = ref<Stats | null>(null)
|
||||
const loading = ref(false)
|
||||
const error = ref<string | null>(null)
|
||||
@@ -21,7 +21,8 @@ export function useStats() {
|
||||
error.value = null
|
||||
|
||||
try {
|
||||
stats.value = await fetchStats()
|
||||
const project = projectRef?.value ?? null
|
||||
stats.value = await fetchStats(project)
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to fetch stats'
|
||||
console.error('[Stats] Error:', err)
|
||||
@@ -54,6 +55,14 @@ export function useStats() {
|
||||
}
|
||||
})
|
||||
|
||||
// Watch for project filter changes
|
||||
if (projectRef) {
|
||||
watch(projectRef, () => {
|
||||
console.log('[Stats] Project filter changed, refreshing stats')
|
||||
refresh()
|
||||
})
|
||||
}
|
||||
|
||||
// Switch between SSE-driven and fallback polling based on connection status
|
||||
watch(isConnected, (connected) => {
|
||||
if (connected) {
|
||||
|
||||
Reference in New Issue
Block a user