[#9954] Add 'view profile' to message long tap

Signed-off-by: yenda <eric@status.im>
This commit is contained in:
Andrey Shovkoplyas 2020-01-31 12:20:27 +01:00 committed by yenda
parent 785f829554
commit c1245d7b1d
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
2 changed files with 30 additions and 13 deletions

View File

@ -13,14 +13,19 @@
(:url content))
(.share react/sharing (clj->js content))))
(defn- message-options [message-id text]
(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)}
(when-not platform/desktop?
{:label (i18n/label :t/sharing-share)
:action #(open-share {:message text})})])
:action #(open-share {:message text})}])))
(defn show [options]
(cond
@ -28,9 +33,9 @@
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 []

View File

@ -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}]
@ -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