11import { CommonModule , IMAGE_LOADER , NgOptimizedImage } from '@angular/common' ;
2- import { Component , HostListener , computed , effect , input , signal } from '@angular/core' ;
2+ import { Component , computed , effect , input , signal } from '@angular/core' ;
33import { Proposition } from 'src/api/listen-and-write' ;
44import { minioVariantImageLoader } from '../../shared/image-loaders/minio-variant-image.loader' ;
5- import { BrowserService } from '../../core/services/browser.service' ;
65
76@Component ( {
87 selector : 'app-news-image' ,
@@ -19,29 +18,18 @@ import { BrowserService } from '../../core/services/browser.service';
1918export class NewsImageComponent {
2019
2120 proposition = input < Proposition | null > ( ) ;
22- private readonly mobileMaxWidth = 600 ;
23- private readonly mobileSrcset = '320w, 512w, 640w' ;
24- private readonly desktopSrcset = '320w, 512w, 640w, 1024w' ;
21+ private readonly unifiedSrcset = '320w, 512w, 640w, 1024w' ;
2522 readonly imageLoaderParams = { defaultWidth : 640 } ;
26- readonly isMobileLayout = signal ( false ) ;
27- readonly imageSrcset = computed ( ( ) => (
28- this . isMobileLayout ( ) ? this . mobileSrcset : this . desktopSrcset
29- ) ) ;
23+ readonly imageSrcset = computed ( ( ) => this . unifiedSrcset ) ;
3024 imageLoadFailed = signal ( false ) ;
3125
3226 imageBaseId = computed ( ( ) => this . getImageBaseId ( this . proposition ( ) ?. imageFileId ) ) ;
3327
34- constructor ( private browserService : BrowserService ) {
28+ constructor ( ) {
3529 effect ( ( ) => {
3630 this . proposition ( ) ;
3731 this . imageLoadFailed . set ( false ) ;
3832 } ) ;
39- this . updateMobileLayout ( ) ;
40- }
41-
42- @HostListener ( 'window:resize' )
43- onWindowResize ( ) : void {
44- this . updateMobileLayout ( ) ;
4533 }
4634
4735 onOptimizedImageError ( ) : void {
@@ -56,9 +44,4 @@ export class NewsImageComponent {
5644 const baseId = lastDot > 0 ? imageFileId . slice ( 0 , lastDot ) : imageFileId ;
5745 return baseId . replace ( / _ w \d + $ / , '' ) ;
5846 }
59-
60- private updateMobileLayout ( ) : void {
61- const width = this . browserService . getWindowWidth ( ) ;
62- this . isMobileLayout . set ( width > 0 && width <= this . mobileMaxWidth ) ;
63- }
6447}
0 commit comments