Skip to content

Commit

Permalink
display the latest image
Browse files Browse the repository at this point in the history
  • Loading branch information
Lan Le authored and PiTrem committed May 10, 2022
1 parent 8903f51 commit e2d2b93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/api/entities/container_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ def preview_img(container_ids, attachments)
attachments = attachments.select do |a|
a.thumb == true && a.attachable_type == 'Container' && container_ids.include?(a.attachable_id)
end

image_atts = attachments.select do |a_img|
a_img&.content_type&.match(Regexp.union(%w[jpg jpeg png tiff]))
end

image_atts = image_atts.sort_by{ |a_img| a_img[:id] }.reverse

attachment = image_atts[0] || attachments[0]

preview = attachment.read_thumbnail if attachment
Expand Down
5 changes: 4 additions & 1 deletion app/packs/src/components/stores/SpectraStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ class SpectraStore {
decodeSpectra(fetchedFiles = {}) {
const { files } = fetchedFiles;
if (!files) return [];
return files.map(f => this.decodeSpectrum(f)).filter(r => r !== null);
const returnFiles = files.map(f => this.decodeSpectrum(f)).filter(r => r !== null);
return returnFiles.sort(function(a, b) {
return b.idx - a.idx;
});
}

handleToggleModal() {
Expand Down

0 comments on commit e2d2b93

Please sign in to comment.