@@ -8,6 +8,7 @@ import { ReactComponent as CalendarSvg } from '@/assets/icons/calendar.svg';
88import { ReactComponent as GridSvg } from '@/assets/icons/grid.svg' ;
99import { ReactComponent as DocumentSvg } from '@/assets/icons/page.svg' ;
1010import { cn } from '@/lib/utils' ;
11+ import { getImageUrl , revokeBlobUrl } from '@/utils/authenticated-image' ;
1112import { renderColor } from '@/utils/color' ;
1213import { getIcon , isFlagEmoji } from '@/utils/emoji' ;
1314
@@ -24,6 +25,7 @@ function PageIcon({
2425 iconSize ?: number ;
2526} ) {
2627 const [ iconContent , setIconContent ] = React . useState < string | undefined > ( undefined ) ;
28+ const [ imgSrc , setImgSrc ] = React . useState < string | undefined > ( undefined ) ;
2729
2830 const emoji = useMemo ( ( ) => {
2931 if ( view . icon && view . icon . ty === ViewIconType . Emoji && view . icon . value ) {
@@ -33,17 +35,36 @@ function PageIcon({
3335 return null ;
3436 } , [ view ] ) ;
3537
36- const img = useMemo ( ( ) => {
38+ useEffect ( ( ) => {
39+ let currentBlobUrl : string | undefined ;
40+
3741 if ( view . icon && view . icon . ty === ViewIconType . URL && view . icon . value ) {
42+ void getImageUrl ( view . icon . value ) . then ( ( url ) => {
43+ currentBlobUrl = url ;
44+ setImgSrc ( url ) ;
45+ } ) ;
46+ } else {
47+ setImgSrc ( undefined ) ;
48+ }
49+
50+ return ( ) => {
51+ if ( currentBlobUrl ) {
52+ revokeBlobUrl ( currentBlobUrl ) ;
53+ }
54+ } ;
55+ } , [ view . icon ] ) ;
56+
57+ const img = useMemo ( ( ) => {
58+ if ( imgSrc ) {
3859 return (
3960 < span className = { cn ( 'h-full w-full p-[2px]' , className ) } >
40- < img className = { 'h-full w-full' } src = { view . icon . value } alt = 'icon' />
61+ < img className = { 'h-full w-full' } src = { imgSrc } alt = 'icon' />
4162 </ span >
4263 ) ;
4364 }
4465
4566 return null ;
46- } , [ className , view . icon ] ) ;
67+ } , [ className , imgSrc ] ) ;
4768
4869 const isFlag = useMemo ( ( ) => {
4970 return emoji ? isFlagEmoji ( emoji ) : false ;
0 commit comments