fix(analysis): preserve catchphrase member filter

This commit is contained in:
digua committed 2026-07-16 23:28:17 +08:00
1 parent 4925fa0676
commit 6d2ad097a3
3 files changed
+31 -3

No files matched your search

@@ -8,6 +8,7 @@ import { EmptyState, LoadingState, SectionCard } from '@/components/UI'
import { useLayoutStore } from '@/stores/layout'
import { formatRankNumber, getRankNumberClass } from '@/utils'
import type { TimeFilter } from '@openchatlab/shared-types'
import { buildCatchphraseRecordQuery } from './catchphrase-record-query'
const { t } = useI18n()
const layoutStore = useLayoutStore()
@@ -45,9 +46,7 @@ async function loadCatchphraseAnalysis() {
}
function handlePhraseClick(content: string) {
layoutStore.openChatRecordDrawer({
keywords: [content],
})
layoutStore.openChatRecordDrawer(buildCatchphraseRecordQuery(content, props.timeFilter))
}
function getOverviewPhrases(member: MemberCatchphrase) {
@@ -0,0 +1,20 @@
/**
* Run: pnpm test -- src/components/analysis/quotes/catchphrase-record-query.test.ts
*/
import assert from 'node:assert/strict'
import test from 'node:test'
import { buildCatchphraseRecordQuery } from './catchphrase-record-query'
test('keeps the selected member when opening catchphrase records', () => {
assert.deepEqual(buildCatchphraseRecordQuery('口头禅', { memberId: 42 }), {
keywords: ['口头禅'],
memberId: 42,
})
})
test('keeps overview catchphrase records scoped only by keyword', () => {
assert.deepEqual(buildCatchphraseRecordQuery('口头禅'), {
keywords: ['口头禅'],
})
})
@@ -0,0 +1,9 @@
import type { TimeFilter } from '@openchatlab/shared-types'
import type { ChatRecordQuery } from '@/types/format'
export function buildCatchphraseRecordQuery(content: string, timeFilter?: TimeFilter): ChatRecordQuery {
return {
keywords: [content],
...(timeFilter?.memberId != null ? { memberId: timeFilter.memberId } : {}),
}
}