@@ -256,35 +256,7 @@ export class PhotoswipeService {
256
256
errorMsgText . className = 'pswp-error-text' ;
257
257
errorMsgEl . appendChild ( errorMsgText ) ;
258
258
259
- const renderButton = document . createElement ( 'button' ) ;
260
- renderButton . setAttribute ( 'mat-stroked-button' , '' ) ;
261
- const psdButtonComponent = createComponent ( MatButton , {
262
- environmentInjector : this . injector ,
263
- hostElement : renderButton ,
264
- projectableNodes : [
265
- [ document . createTextNode ( 'Load render from Hydrus' ) ]
266
- ]
267
- } )
268
-
269
- const buttonContainer = document . createElement ( 'div' ) ;
270
- buttonContainer . className = 'pswp-error-text' ;
271
- errorMsgEl . appendChild ( buttonContainer ) ;
272
- buttonContainer . appendChild ( renderButton ) ;
273
- this . appRef . attachView ( psdButtonComponent . hostView ) ;
274
-
275
- renderButton . addEventListener ( 'click' , async ( ev ) => {
276
- psdButtonComponent . setInput ( 'disabled' , true ) ;
277
- const data = {
278
- type : 'image' ,
279
- src : file . render_url ,
280
- msrc : file . thumbnail_url ,
281
- width : file . width ,
282
- height : file . height ,
283
- file
284
- }
285
- this . processedFiles . set ( file . hash , data ) ;
286
- pswp . refreshSlideContent ( content . index ) ;
287
- } )
259
+ this . addRenderButton ( file , errorMsgEl , pswp , content ) ;
288
260
289
261
this . addPhotopeaButton ( file , errorMsgEl ) ;
290
262
@@ -369,6 +341,10 @@ export class PhotoswipeService {
369
341
errorMsgText . className = 'pswp-error-text' ;
370
342
errorMsgEl . appendChild ( errorMsgText ) ;
371
343
344
+ if ( file . render_url ) {
345
+ this . addRenderButton ( file , errorMsgEl , pswp , content ) ;
346
+ }
347
+
372
348
return errorMsgEl ;
373
349
} ) ;
374
350
@@ -468,7 +444,7 @@ export class PhotoswipeService {
468
444
}
469
445
}
470
446
471
- addPhotopeaButton ( file : HydrusBasicFile , element : HTMLElement ) {
447
+ private addPhotopeaButton ( file : HydrusBasicFile , element : HTMLElement ) {
472
448
if ( canOpenInPhotopea ( file ) && this . settingsService . appSettings . photopeaIntegration ) {
473
449
const photopeaButton = document . createElement ( 'a' ) ;
474
450
photopeaButton . setAttribute ( 'mat-stroked-button' , '' ) ;
@@ -492,4 +468,36 @@ export class PhotoswipeService {
492
468
}
493
469
}
494
470
471
+ private addRenderButton ( file : HydrusBasicFile , element : HTMLElement , pswp : PhotoSwipe , content : Content ) {
472
+ const renderButton = document . createElement ( 'button' ) ;
473
+ renderButton . setAttribute ( 'mat-stroked-button' , '' ) ;
474
+ const psdButtonComponent = createComponent ( MatButton , {
475
+ environmentInjector : this . injector ,
476
+ hostElement : renderButton ,
477
+ projectableNodes : [
478
+ [ document . createTextNode ( 'Load render from Hydrus' ) ]
479
+ ]
480
+ } )
481
+
482
+ const buttonContainer = document . createElement ( 'div' ) ;
483
+ buttonContainer . className = 'pswp-error-text' ;
484
+ element . appendChild ( buttonContainer ) ;
485
+ buttonContainer . appendChild ( renderButton ) ;
486
+ this . appRef . attachView ( psdButtonComponent . hostView ) ;
487
+
488
+ renderButton . addEventListener ( 'click' , async ( ev ) => {
489
+ psdButtonComponent . setInput ( 'disabled' , true ) ;
490
+ const data = {
491
+ type : 'image' ,
492
+ src : file . render_url ,
493
+ msrc : file . thumbnail_url ,
494
+ width : file . width ,
495
+ height : file . height ,
496
+ file
497
+ }
498
+ this . processedFiles . set ( file . hash , data ) ;
499
+ pswp . refreshSlideContent ( content . index ) ;
500
+ } )
501
+ }
502
+
495
503
}
0 commit comments