@@ -21,6 +21,8 @@ qx.Class.define("osparc.ui.table.cellrenderer.ImageButtonRenderer", {
2121 construct : function ( clickAction , iconPath ) {
2222 this . base ( arguments , clickAction ) ;
2323
24+ this . __imageCache = { } ;
25+
2426 this . setIconPath ( iconPath ) ;
2527 } ,
2628
@@ -34,11 +36,43 @@ qx.Class.define("osparc.ui.table.cellrenderer.ImageButtonRenderer", {
3436 } ,
3537
3638 members : {
39+ __imageCache : null ,
40+
3741 __applyIconPath : function ( iconPath ) {
3842 const resMgr = qx . util . ResourceManager . getInstance ( ) ;
39- const iconUrl = resMgr . toUri ( iconPath ) ; // Resolves to the correct URL of the asset
43+ const iconUrl = resMgr . toUri ( iconPath ) ;
44+
45+ // Create a data URI or use a more cache-friendly approach
46+ // Use base64 encoding for small icons (best for caching)
47+ this . __loadImageAsDataUri ( iconUrl , iconPath ) ;
48+ } ,
49+
50+ __loadImageAsDataUri : function ( iconUrl , iconPath ) {
51+ if ( this . __imageCache [ iconPath ] ) {
52+ this . setButtonContent ( this . __imageCache [ iconPath ] ) ;
53+ return ;
54+ }
55+
56+ // Fetch and convert to data URI for permanent caching
57+ fetch ( iconUrl )
58+ . then ( response => response . blob ( ) )
59+ . then ( blob => {
60+ const reader = new FileReader ( ) ;
61+ reader . onload = ( ) => {
62+ const dataUri = reader . result ;
63+ const content = `<img src="${ dataUri } " style="width:14px; height:14px;" alt="icon"/>` ;
4064
41- this . setButtonContent ( `<img src="${ iconUrl } " style="width:14x; height:14px;" alt="icon"/>` ) ;
65+ // Cache the data URI
66+ this . __imageCache [ iconPath ] = content ;
67+ this . setButtonContent ( content ) ;
68+ } ;
69+ reader . readAsDataURL ( blob ) ;
70+ } )
71+ . catch ( err => {
72+ console . warn ( "Failed to cache icon as data URI:" , iconPath , err ) ;
73+ // Fallback to original method
74+ this . setButtonContent ( `<img src="${ iconUrl } " style="width:14px; height:14px;" alt="icon"/>` ) ;
75+ } ) ;
4276 } ,
4377 }
4478} ) ;
0 commit comments