import { Injectable } from '@angular/core' ; import { ElectronService } from './electron.service' ; @ Injectable ( { providedIn : 'root' } ) export class AlbumArtService { constructor ( private electronService ) { } private imageCache : { [ songID ] : string ; } = { } ; async getImage ( songID ) { if ( this . imageCache [ songID ] == undefined ) { const albumArtResult = await this . electronService . invoke ( 'album-art' , songID ) ; if ( albumArtResult ) { this . imageCache [ songID ] = albumArtResult . base64Art ; } else { this . imageCache [ songID ] = null ; } } return this . imageCache [ songID ] ; } }