Skip to content

Commit

Permalink
Show uploading status
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed Jan 8, 2024
1 parent 8b0118c commit c74a02e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/jobs/image_collage_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ def perform(entry_id, urls)
entry = Entry.where(id: entry_id).first
return nil unless entry.present?

entry.update(filepicker_url: "https://dabble-me.s3.amazonaws.com/uploading.png")

filestack_collage_url = collage_from_urls(urls + [entry&.image_url_cdn])
entry.update(remote_image_url: filestack_collage_url)
entry.update(remote_image_url: filestack_collage_url, filepicker_url: nil)
end

def collage_from_urls(urls)
Expand Down
4 changes: 4 additions & 0 deletions app/lib/email_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ def process
image_urls = collage_from_attachments([best_attachment])
ImageCollageJob.perform_later(existing_entry.id, image_urls)
elsif best_attachment_url.present?
entry.update(filepicker_url: "https://dabble-me.s3.amazonaws.com/uploading.png")
existing_entry.remote_image_url = collage_from_urls([best_attachment_url, existing_entry.image_url_cdn])
existing_entry.filepicker_url = nil
end
end

Expand All @@ -154,7 +156,9 @@ def process
if best_attachment.present?
entry.image = best_attachment
elsif best_attachment_url.present?
entry.update(filepicker_url: "https://dabble-me.s3.amazonaws.com/uploading.png")
entry.remote_image_url = best_attachment_url
entry.filepicker_url = nil
end
entry.save
rescue ActiveRecord::RecordInvalid => error
Expand Down
2 changes: 2 additions & 0 deletions app/models/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def sanitized_body
def image_url_cdn
if image.present?
image.url
elsif filepicker_url == "https://dabble-me.s3.amazonaws.com/uploading.png"
filepicker_url
end
end

Expand Down

0 comments on commit c74a02e

Please sign in to comment.