@@ -13,12 +13,12 @@ import { Popover2 } from '@blueprintjs/popover2'
13
13
14
14
import clsx from 'clsx'
15
15
import { useAtom } from 'jotai'
16
- import { isEqual } from 'lodash-es'
16
+ import { isEqual , omit } from 'lodash-es'
17
17
import { FC , ReactNode , useRef , useState } from 'react'
18
18
import { useForm } from 'react-hook-form'
19
19
20
20
import { CardDeleteOption } from 'components/editor/CardOptions'
21
- import { favGroupAtom } from 'store/useFavGroups'
21
+ import { favGroupAtom , ignoreKeyDic } from 'store/useFavGroups'
22
22
23
23
import { Group , Operator } from '../../EditorSheet'
24
24
import { GroupListModifyProp } from '../SheetGroup'
@@ -327,7 +327,6 @@ const useSheetGroupItemController = ({
327
327
( { name : nameInFav } ) => nameInFav === name ,
328
328
)
329
329
const pinned = isEqual ( { name, opers } , findFavByName )
330
- console . log ( pinned )
331
330
332
331
const onPinChange : GroupPinOptionProp [ 'onPinChange' ] = ( ) => {
333
332
setFavGroup (
@@ -390,9 +389,12 @@ const useSheetGroupItemController = ({
390
389
}
391
390
}
392
391
case 'fav' : {
393
- const selected = ! ! existedGroups . find (
392
+ const selected = existedGroups . find (
394
393
( { name : nameInExist } ) => nameInExist === name ,
395
394
)
395
+ const equal = selected
396
+ ? isEqual ( omit ( selected , ...ignoreKeyDic ) , { name, opers } )
397
+ : false
396
398
const onPinChange : GroupPinOptionProp [ 'onPinChange' ] = ( ) => {
397
399
setFavGroup (
398
400
favGroup . filter ( ( { name : nameInFav } ) => nameInFav !== name ) ,
@@ -428,8 +430,15 @@ const useSheetGroupItemController = ({
428
430
< >
429
431
< Button
430
432
minimal
431
- icon = { selected ? 'tick' : 'arrow-left' }
432
- title = { selected ? '检测到同名干员组' : '使用该推荐分组' }
433
+ disabled = { ! ! selected }
434
+ icon = { selected && equal ? 'tick' : 'arrow-left' }
435
+ title = {
436
+ selected
437
+ ? equal
438
+ ? '已添加'
439
+ : '检测到同名干员组'
440
+ : '使用该推荐分组'
441
+ }
433
442
onClick = { ( ) => submitGroup ( { name, opers } , undefined , true ) }
434
443
/>
435
444
< GroupPinOption pinned onPinChange = { onPinChange } />
@@ -464,20 +473,23 @@ const GroupPinOption: FC<GroupPinOptionProp> = ({
464
473
: isDuplicate
465
474
? '此操作会替换同名干员组'
466
475
: `添加至收藏分组`
467
- const pinIcon = pinned ? 'star' : isDuplicate ? 'warning-sign' : 'star-empty'
468
476
469
477
return (
470
478
< Popover2
471
479
disabled = { ! pinned && ! isDuplicate }
472
480
content = {
473
481
< Menu className = "p-0" >
474
- < MenuItem text = { pinText } icon = { pinIcon } onClick = { onPinChange } />
482
+ < MenuItem
483
+ text = { pinText }
484
+ icon = { pinned ? 'star' : isDuplicate ? 'warning-sign' : 'star-empty' }
485
+ onClick = { onPinChange }
486
+ />
475
487
</ Menu >
476
488
}
477
489
>
478
490
< Button
479
491
minimal
480
- icon = { pinIcon }
492
+ icon = { pinned ? 'star' : 'star-empty' }
481
493
title = { pinText }
482
494
onClick = { pinned || isDuplicate ? undefined : onPinChange }
483
495
/>
0 commit comments