1
1
import { Flex , Image , Text } from '@invoke-ai/ui-library' ;
2
2
import { skipToken } from '@reduxjs/toolkit/query' ;
3
+ import { useMemo } from 'react' ;
3
4
import { useTranslation } from 'react-i18next' ;
4
- import { useGetBoardAssetsTotalQuery , useGetBoardImagesTotalQuery } from 'services/api/endpoints/boards' ;
5
5
import { useGetImageDTOQuery } from 'services/api/endpoints/images' ;
6
- import type { BoardDTO } from 'services/api/types' ;
7
6
8
7
type Props = {
9
- board : BoardDTO | null ;
8
+ imageCount : number ;
9
+ assetCount : number ;
10
+ isArchived : boolean ;
11
+ coverImageName ?: string | null ;
10
12
} ;
11
13
12
- export const BoardTooltip = ( { board } : Props ) => {
14
+ export const BoardTooltip = ( { imageCount , assetCount , isArchived , coverImageName } : Props ) => {
13
15
const { t } = useTranslation ( ) ;
14
- const { imagesTotal } = useGetBoardImagesTotalQuery ( board ?. board_id || 'none' , {
15
- selectFromResult : ( { data } ) => {
16
- return { imagesTotal : data ?. total ?? 0 } ;
17
- } ,
18
- } ) ;
19
- const { assetsTotal } = useGetBoardAssetsTotalQuery ( board ?. board_id || 'none' , {
20
- selectFromResult : ( { data } ) => {
21
- return { assetsTotal : data ?. total ?? 0 } ;
22
- } ,
23
- } ) ;
24
- const { currentData : coverImage } = useGetImageDTOQuery ( board ?. cover_image_name ?? skipToken ) ;
16
+ const { currentData : coverImage } = useGetImageDTOQuery ( coverImageName ?? skipToken ) ;
17
+
18
+ const totalString = useMemo ( ( ) => {
19
+ return `${ t ( 'boards.imagesWithCount' , { count : imageCount } ) } , ${ t ( 'boards.assetsWithCount' , { count : assetCount } ) } ${ isArchived ? ` (${ t ( 'boards.archived' ) } )` : '' } ` ;
20
+ } , [ assetCount , imageCount , isArchived , t ] ) ;
25
21
26
22
return (
27
23
< Flex flexDir = "column" alignItems = "center" gap = { 1 } >
@@ -34,13 +30,11 @@ export const BoardTooltip = ({ board }: Props) => {
34
30
aspectRatio = "1/1"
35
31
borderRadius = "base"
36
32
borderBottomRadius = "lg"
33
+ mt = { 1 }
37
34
/>
38
35
) }
39
36
< Flex flexDir = "column" alignItems = "center" >
40
- < Text noOfLines = { 1 } >
41
- { t ( 'boards.imagesWithCount' , { count : imagesTotal } ) } , { t ( 'boards.assetsWithCount' , { count : assetsTotal } ) }
42
- </ Text >
43
- { board ?. archived && < Text > ({ t ( 'boards.archived' ) } )</ Text > }
37
+ < Text noOfLines = { 1 } > { totalString } </ Text >
44
38
</ Flex >
45
39
</ Flex >
46
40
) ;
0 commit comments