From 0ead731239ceb1b5c4f5743d74a82e463fac5380 Mon Sep 17 00:00:00 2001 From: Andrey Shovkoplyas Date: Fri, 30 Nov 2018 15:25:52 +0100 Subject: [PATCH] [#6958] Only render command message when relevant Signed-off-by: Andrey Shovkoplyas --- .../ui/screens/chat/message/message.cljs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/status_im/ui/screens/chat/message/message.cljs b/src/status_im/ui/screens/chat/message/message.cljs index 57ee59b8c2..6b94a5c2f9 100644 --- a/src/status_im/ui/screens/chat/message/message.cljs +++ b/src/status_im/ui/screens/chat/message/message.cljs @@ -15,7 +15,8 @@ [status-im.utils.platform :as platform] [status-im.i18n :as i18n] [status-im.ui.components.colors :as colors] - [status-im.ui.components.icons.vector-icons :as icons])) + [status-im.ui.components.icons.vector-icons :as icons] + [status-im.chat.commands.protocol :as protocol])) (defn install-extension-message [extension-id outgoing] [react/touchable-highlight {:on-press #(re-frame/dispatch @@ -30,11 +31,16 @@ (defview message-content-command [command-message] (letsubs [id->command [:chats/id->command]] - (if-let [command (commands-receiving/lookup-command-by-ref command-message id->command)] - (commands/generate-preview command command-message) - (if-let [extension-id (get-in command-message [:content :params :extension-id])] + (let [{:keys [type] :as command} (commands-receiving/lookup-command-by-ref command-message id->command) + extension-id (get-in command-message [:content :params :extension-id])] + (if (and platform/mobile? extension-id (or (not type) (and type (satisfies? protocol/Extension type) + (not= extension-id (protocol/extension-id type))))) + ;; Show install message only for mobile and if message contains extension id and there is no extension installed + ;; or installed extension has differen extension id [install-extension-message extension-id (:outgoing command-message)] - [react/text (str "Unhandled command: " (-> command-message :content :command-path first))])))) + (if command + (commands/generate-preview command command-message) + [react/text (str "Unhandled command: " (-> command-message :content :command-path first))]))))) (defview message-timestamp [t justify-timestamp? outgoing command? content] (when-not command?