Skip to content

Commit

Permalink
fix(flowfact): Move 'mainImage' to first index in attachment array
Browse files Browse the repository at this point in the history
  • Loading branch information
jroehl committed Jul 20, 2020
1 parent 83aad63 commit 239bd67
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/classes/portals/FlowFact/v2/Estate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,33 @@ export class FlowFactEstateV2 extends Estate {
}

private async getAttachments(): Promise<Attachment[]> {
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;
}
}

0 comments on commit 239bd67

Please sign in to comment.