@@ -7,23 +7,33 @@ import {
7
7
} from '@blueprintjs/core'
8
8
9
9
import { UseOperationsParams } from 'apis/operation'
10
- import { useAtom } from 'jotai'
10
+ import { useAtom , useAtomValue } from 'jotai'
11
11
import { debounce } from 'lodash-es'
12
12
import { ComponentType , useMemo , useState } from 'react'
13
13
14
14
import { CardTitle } from 'components/CardTitle'
15
15
import { OperationList } from 'components/OperationList'
16
16
import { OperationSetList } from 'components/OperationSetList'
17
17
import { neoLayoutAtom } from 'store/pref'
18
+ import {
19
+ selectedOperatorQueryAtom ,
20
+ selectedOperatorsAtom ,
21
+ } from 'store/selectedOperators'
18
22
19
23
import { authAtom } from '../store/auth'
20
24
import { OperatorSelect } from './OperatorSelect'
21
25
import { withSuspensable } from './Suspensable'
22
26
23
27
export const Operations : ComponentType = withSuspensable ( ( ) => {
24
- const [ queryParams , setQueryParams ] = useState < UseOperationsParams > ( {
28
+ const [ queryParams , setQueryParams ] = useState <
29
+ Omit < UseOperationsParams , 'operator' >
30
+ > ( {
25
31
orderBy : 'hot' ,
26
32
} )
33
+ const [ selectedOperators , setSelectedOperators ] = useAtom (
34
+ selectedOperatorsAtom ,
35
+ )
36
+ const selectedOperatorQuery = useAtomValue ( selectedOperatorQueryAtom )
27
37
const debouncedSetQueryParams = useMemo (
28
38
( ) => debounce ( setQueryParams , 500 ) ,
29
39
[ ] ,
@@ -95,7 +105,7 @@ export const Operations: ComponentType = withSuspensable(() => {
95
105
< div className = "flex mr-4" >
96
106
< FormGroup
97
107
helperText = {
98
- queryParams . operator ? .length
108
+ selectedOperators . length
99
109
? '点击干员标签以标记为排除该干员'
100
110
: undefined
101
111
}
@@ -135,13 +145,8 @@ export const Operations: ComponentType = withSuspensable(() => {
135
145
/>
136
146
< OperatorSelect
137
147
className = "mt-2"
138
- operators = { queryParams . operator ?. split ( ',' ) || [ ] }
139
- onChange = { ( operators ) =>
140
- setQueryParams ( ( old ) => ( {
141
- ...old ,
142
- operator : operators . join ( ',' ) ,
143
- } ) )
144
- }
148
+ operators = { selectedOperatorQuery . split ( ',' ) }
149
+ onChange = { setSelectedOperators }
145
150
/>
146
151
</ FormGroup >
147
152
</ div >
@@ -210,9 +215,12 @@ export const Operations: ComponentType = withSuspensable(() => {
210
215
</ Card >
211
216
212
217
< div className = "tabular-nums" >
213
- { listMode === 'operation' && < OperationList { ...queryParams } /> }
218
+ { listMode === 'operation' && (
219
+ < OperationList { ...queryParams } operator = { selectedOperatorQuery } />
220
+ ) }
214
221
{ listMode === 'operationSet' && < OperationSetList { ...queryParams } /> }
215
222
</ div >
216
223
</ >
217
224
)
218
225
} )
226
+ Operations . displayName = 'Operations'
0 commit comments