Skip to content

Add fallback/default dimensions for Image sent from desktop #17966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/status_im2/contexts/chat/messages/content/image/view.cljs
Original file line number Diff line number Diff line change
@@ -8,14 +8,23 @@
[utils.re-frame :as rf]
[utils.url :as url]))

;; these constants are used when there is no width or height defined for a specific image
(def ^:const fallback-image-width 1000)
(def ^:const fallback-image-height 1000)

(defn calculate-dimensions
[width height max-container-width max-container-height]
(let [max-width (if (> width height) max-container-width (* 1.5 constants/image-size))
max-height (if (> width height) max-container-height (* 2 constants/image-size))]
{:width (min width max-width) :height (min height max-height)}))

(defn image-message
[index {:keys [content image-width image-height message-id] :as message} {:keys [on-long-press]}
[index
{:keys [content image-width image-height message-id]
:as message
:or {image-width fallback-image-width
image-height fallback-image-height}}
{:keys [on-long-press]}
message-container-data]
(let [insets (safe-area/get-insets)
{:keys [window-width padding-left padding-right avatar-container-width