@@ -36,9 +36,45 @@ qx.Class.define("osparc.ui.table.cellrenderer.ImageButtonRenderer", {
3636 members : {
3737 __applyIconPath : function ( iconPath ) {
3838 const resMgr = qx . util . ResourceManager . getInstance ( ) ;
39- const iconUrl = resMgr . toUri ( iconPath ) ; // Resolves to the correct URL of the asset
39+ const iconUrl = resMgr . toUri ( iconPath ) ;
4040
41- this . setButtonContent ( `<img src="${ iconUrl } " style="width:14x; height:14px;" alt="icon"/>` ) ;
41+ // Create a data URI or use a more cache-friendly approach
42+ // Use base64 encoding for small icons (best for caching)
43+ this . __loadImageAsDataUri ( iconUrl , iconPath ) ;
44+ } ,
45+
46+ __loadImageAsDataUri : function ( iconUrl , iconPath ) {
47+ // Try to use a cached version first
48+ if ( this . constructor . __imageCache && this . constructor . __imageCache [ iconPath ] ) {
49+ this . setButtonContent ( this . constructor . __imageCache [ iconPath ] ) ;
50+ return ;
51+ }
52+
53+ // Initialize cache if it doesn't exist
54+ if ( ! this . constructor . __imageCache ) {
55+ this . constructor . __imageCache = { } ;
56+ }
57+
58+ // Fetch and convert to data URI for permanent caching
59+ fetch ( iconUrl )
60+ . then ( response => response . blob ( ) )
61+ . then ( blob => {
62+ const reader = new FileReader ( ) ;
63+ reader . onload = ( ) => {
64+ const dataUri = reader . result ;
65+ const content = `<img src="${ dataUri } " style="width:14px; height:14px;" alt="icon"/>` ;
66+
67+ // Cache the data URI
68+ this . constructor . __imageCache [ iconPath ] = content ;
69+ this . setButtonContent ( content ) ;
70+ } ;
71+ reader . readAsDataURL ( blob ) ;
72+ } )
73+ . catch ( err => {
74+ console . warn ( "Failed to cache icon as data URI:" , iconPath , err ) ;
75+ // Fallback to original method
76+ this . setButtonContent ( `<img src="${ iconUrl } " style="width:14px; height:14px;" alt="icon"/>` ) ;
77+ } ) ;
4278 } ,
4379 }
4480} ) ;
0 commit comments