import { FileMultiFormats , ResolvedProfilePictureUrls } from 'src/types' ; import { vuexStore } from 'src/store' ; const $store = vuexStore ; export default class MultiFormatPicture { private rootUrl : string ; constructor ( private imageBase ? ) { this . imageBase = imageBase ; this . rootUrl = $store ?. getters [ 'getRootURL' ] as string ; } public get imageUrls ( ) : ResolvedProfilePictureUrls | null { if ( ! this . imageBase ) return null ; const profilePictureFormat = { thumbnail : undefined , small : undefined , original : undefined } ; if ( this . imageBase ) { profilePictureFormat . thumbnail = this . imageBase ?. formats ?. thumbnail ?. url ?? undefined ; profilePictureFormat . small = this . imageBase ?. formats ?. small ?. url ?? undefined ; profilePictureFormat . original = this . imageBase ?. url ?? undefined ; } return { thumbnail : profilePictureFormat ?. thumbnail ? `${ this . rootUrl }/${ profilePictureFormat . thumbnail }` : undefined , small : profilePictureFormat . small ? `${ this . rootUrl }/${ profilePictureFormat . small }` : undefined , original : profilePictureFormat . original ? `${ this . rootUrl }/${ profilePictureFormat . original }` : undefined , } ; } public get avatarImageUrl ( ) { const imageUrls = this . imageUrls ; if ( ! imageUrls ) return '' ; return imageUrls . thumbnail ?? imageUrls . small ?? imageUrls . original ?? '' ; } }