diff --git a/src/classes/portals/FlowFact/v2/Estate.ts b/src/classes/portals/FlowFact/v2/Estate.ts index e645ba4..341250f 100644 --- a/src/classes/portals/FlowFact/v2/Estate.ts +++ b/src/classes/portals/FlowFact/v2/Estate.ts @@ -133,12 +133,33 @@ export class FlowFactEstateV2 extends Estate { } private async getAttachments(): Promise { - return this.getValue('onlineImage.values', []).map( + const onlineImages: Attachment[] = this.getValue( + 'onlineImage.values', + [] + ).map( (attachment: any) => ({ title: get(attachment, 'headline'), url: get(attachment, 'uri'), } as Attachment) ); + + const mainImage = this.getValue('mainImage.values[0]'); + + if (mainImage) { + const main: Attachment = { + title: get(mainImage, 'headline'), + url: get(mainImage, 'uri'), + }; + + return [ + main, + ...onlineImages.filter( + (attachment: Attachment) => attachment.url !== main.url + ), + ]; + } + + return onlineImages; } }