Skip to content

Commit

Permalink
[#9954] Add 'view profile' to message long tap
Browse files Browse the repository at this point in the history
Signed-off-by: yenda <eric@status.im>
  • Loading branch information
flexsurfer authored and yenda committed Feb 3, 2020
1 parent 785f829 commit c1245d7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
23 changes: 14 additions & 9 deletions src/status_im/ui/components/list_selection.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,29 @@
(:url content))
(.share react/sharing (clj->js content))))

(defn- message-options [message-id text]
[{:label (i18n/label :t/message-reply)
:action #(re-frame/dispatch [:chat.ui/reply-to-message message-id])}
{:label (i18n/label :t/sharing-copy-to-clipboard)
:action #(react/copy-to-clipboard text)}
(when-not platform/desktop?
(defn- message-options [message-id text from outgoing]
(into
[]
(concat
(when (and from (not outgoing))
[{:label (i18n/label :t/view-profile)
:action #(re-frame/dispatch [:chat.ui/show-profile from])}])
[{:label (i18n/label :t/message-reply)
:action #(re-frame/dispatch [:chat.ui/reply-to-message message-id])}
{:label (i18n/label :t/sharing-copy-to-clipboard)
:action #(react/copy-to-clipboard text)}
{:label (i18n/label :t/sharing-share)
:action #(open-share {:message text})})])
:action #(open-share {:message text})}])))

(defn show [options]
(cond
platform/ios? (action-sheet/show options)
platform/android? (dialog/show options)
platform/desktop? (show-desktop-menu (->> (:options options) (remove nil?)))))

(defn chat-message [message-id text dialog-title]
(defn chat-message [message-id text from outgoing dialog-title]
(show {:title dialog-title
:options (message-options message-id text)
:options (message-options message-id text from outgoing)
:cancel-text (i18n/label :t/message-options-cancel)}))

(defn- platform-web-browser []
Expand Down
20 changes: 16 additions & 4 deletions src/status_im/ui/screens/chat/message/message.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,17 @@
[message-delivery-status message]]])

(defn open-chat-context-menu
[{:keys [message-id content] :as message}]
(list-selection/chat-message message-id (:text content) (i18n/label :t/message)))
[{:keys [message-id content from outgoing]}]
(list-selection/chat-message message-id (:text content) from outgoing (i18n/label :t/message)))

(defn open-sticker-context-menu
[{:keys [from outgoing]}]
(when (and from (not outgoing))
(list-selection/show
{:title (i18n/label :t/message)
:options [{:label (i18n/label :t/view-profile)
:action #(re-frame/dispatch [:chat.ui/show-profile from])}]
:cancel-text (i18n/label :t/message-options-cancel)})))

(defn chat-message
[{:keys [outgoing group-chat modal? current-public-key content-type content] :as message}]
Expand All @@ -539,9 +548,12 @@
:input-bottom-sheet nil}])
(when-not platform/desktop?
(react/dismiss-keyboard!)))))
:on-long-press #(when (or (= content-type constants/content-type-text)
:on-long-press #(cond (or (= content-type constants/content-type-text)
(= content-type constants/content-type-emoji))
(open-chat-context-menu message))}
(open-chat-context-menu message)

(= content-type constants/content-type-sticker)
(open-sticker-context-menu message))}
[react/view {:accessibility-label :chat-item}
(let [incoming-group (and group-chat (not outgoing))]
[message-content message-body (merge message
Expand Down

0 comments on commit c1245d7

Please sign in to comment.