@@ -21,23 +21,23 @@ export default class RecordImageCarousel extends LightningElement {
2121 wiredImagesResult ;
2222 refreshInterval ;
2323 lastImageCount = 0 ;
24-
24+
2525 connectedCallback ( ) {
2626 // Set up auto-refresh every 30 seconds to detect external file uploads
2727 this . refreshInterval = setInterval ( ( ) => {
2828 this . checkForNewImages ( ) ;
2929 } , 30000 ) ;
3030 }
31-
31+
3232 disconnectedCallback ( ) {
3333 if ( this . refreshInterval ) {
3434 clearInterval ( this . refreshInterval ) ;
3535 }
3636 }
37-
37+
3838 renderedCallback ( ) {
3939 // Set the custom height CSS property
40- if ( this . template . host ) {
40+ if ( this . template . host && this . template . host . style ) {
4141 this . template . host . style . setProperty ( '--carousel-height' , `${ this . carouselHeight } px` ) ;
4242 }
4343 }
@@ -60,7 +60,7 @@ export default class RecordImageCarousel extends LightningElement {
6060
6161 // Process the images for the carousel
6262 processImages ( images ) {
63-
63+
6464 if ( images && images . length > 0 ) {
6565 // Store images with formatted descriptions directly
6666 this . imageData = images . map ( image => ( {
@@ -71,7 +71,7 @@ export default class RecordImageCarousel extends LightningElement {
7171 fileExtension : image . fileExtension ,
7272 contentSize : image . contentSize
7373 } ) ) ;
74-
74+
7575 // Update last image count for auto-refresh detection
7676 this . lastImageCount = this . imageData . length ;
7777 } else {
@@ -112,15 +112,15 @@ export default class RecordImageCarousel extends LightningElement {
112112 get hasImages ( ) {
113113 return this . imageData && this . imageData . length > 0 ;
114114 }
115-
115+
116116 get imageDataLength ( ) {
117117 return this . imageData ? this . imageData . length : 0 ;
118118 }
119119
120120 // Event handlers
121121 handleImageClick ( event ) {
122122 const imageId = event . target . dataset . imageId ;
123-
123+
124124 // Find the clicked image
125125 const clickedImage = this . imageData . find ( img => img . contentVersionId === imageId ) ;
126126 if ( clickedImage ) {
@@ -145,7 +145,7 @@ export default class RecordImageCarousel extends LightningElement {
145145 variant : 'success' ,
146146 } )
147147 ) ;
148-
148+
149149 // Refresh the component to show the new image
150150 this . refreshImages ( ) ;
151151 }
@@ -165,10 +165,10 @@ export default class RecordImageCarousel extends LightningElement {
165165 try {
166166 // Only check if we have a record ID and aren't currently loading
167167 if ( ! this . recordId || this . isLoading ) return ;
168-
168+
169169 // Refresh to get latest count
170170 await refreshApex ( this . wiredImagesResult ) ;
171-
171+
172172 // If image count increased, show notification
173173 if ( this . imageData . length > this . lastImageCount ) {
174174 this . dispatchEvent (
@@ -179,7 +179,7 @@ export default class RecordImageCarousel extends LightningElement {
179179 } )
180180 ) ;
181181 }
182-
182+
183183 this . lastImageCount = this . imageData . length ;
184184 } catch ( error ) {
185185 // Silently handle errors in background refresh
@@ -203,12 +203,12 @@ export default class RecordImageCarousel extends LightningElement {
203203 link . href = url ;
204204 link . download = filename || 'image' ;
205205 link . target = '_blank' ;
206-
206+
207207 // Append to body, click, and remove
208208 document . body . appendChild ( link ) ;
209209 link . click ( ) ;
210210 document . body . removeChild ( link ) ;
211-
211+
212212 // Show success message
213213 this . dispatchEvent (
214214 new ShowToastEvent ( {
0 commit comments