1+ import { NgOptimizedImage } from '@angular/common' ;
12import { ChangeDetectionStrategy , Component , computed , signal } from '@angular/core' ;
23import { CodeArticleComponent } from '@csss-code/article/article.component' ;
34import { ExternalLinkComponent } from 'components/url/external-link/external-link.component' ;
@@ -6,12 +7,13 @@ import { ExecutiveAdministration, executives } from './officers.data';
67
78@Component ( {
89 selector : 'cs-officers' ,
9- imports : [ CodeArticleComponent , RouteLinkComponent , ExternalLinkComponent ] ,
10+ imports : [ CodeArticleComponent , RouteLinkComponent , ExternalLinkComponent , NgOptimizedImage ] ,
1011 templateUrl : './officers.component.html' ,
1112 styleUrl : './officers.component.scss' ,
1213 changeDetection : ChangeDetectionStrategy . OnPush
1314} )
1415export class OfficersComponent {
16+ protected PRIORITY = 10 ;
1517 /**
1618 * The year currently selected.
1719 */
@@ -46,4 +48,16 @@ export class OfficersComponent {
4648 * Will probably need some way to remove older cached entries if memory becomes an issue.
4749 */
4850 private cachedAdmins = new Map < number , ExecutiveAdministration > ( ) ;
51+
52+ private loadedImages = signal ( new Set < number > ( ) ) ;
53+
54+ areImagesLoaded = computed (
55+ ( ) =>
56+ this . loadedImages ( ) . size >= ( this . currentAdministration ( ) ?. members ?? [ ] ) . length ||
57+ this . loadedImages ( ) . size >= this . PRIORITY
58+ ) ;
59+
60+ onLoad ( id : number ) : void {
61+ this . loadedImages . update ( ids => new Set ( [ ...ids , id ] ) ) ;
62+ }
4963}
0 commit comments