Command as the last message (#367)
This commit is contained in:
parent
e239363c1e
commit
dc3d9f8931
|
@ -4,13 +4,10 @@
|
||||||
text
|
text
|
||||||
image
|
image
|
||||||
touchable-highlight]]
|
touchable-highlight]]
|
||||||
[status-im.chats-list.views.inner-item :refer [chat-list-item-inner-view]]))
|
[status-im.chats-list.views.inner-item :refer [chat-list-item-inner-view]]
|
||||||
|
[taoensso.timbre :as log]))
|
||||||
|
|
||||||
(defn chat-list-item [[chat-id chat]]
|
(defn chat-list-item [[chat-id chat]]
|
||||||
[touchable-highlight {:on-press #(dispatch [:navigate-to :chat chat-id])}
|
[touchable-highlight {:on-press #(dispatch [:navigate-to :chat chat-id])}
|
||||||
[view
|
[view
|
||||||
[chat-list-item-inner-view (merge chat
|
[chat-list-item-inner-view (assoc chat :chat-id chat-id)]]])
|
||||||
;; TODO stub data
|
|
||||||
{:chat-id chat-id
|
|
||||||
:new-messages-count 3
|
|
||||||
:online true})]]])
|
|
||||||
|
|
|
@ -1,20 +1,37 @@
|
||||||
(ns status-im.chats-list.views.inner-item
|
(ns status-im.chats-list.views.inner-item
|
||||||
(:require-macros [status-im.utils.views :refer [defview]])
|
(:require-macros [status-im.utils.views :refer [defview]])
|
||||||
(:require [status-im.components.react :refer [view image icon text]]
|
(:require [re-frame.core :refer [subscribe dispatch]]
|
||||||
|
[clojure.string :as str]
|
||||||
|
[status-im.components.react :refer [view image icon text]]
|
||||||
[status-im.components.chat-icon.screen :refer [chat-icon-view-chat-list]]
|
[status-im.components.chat-icon.screen :refer [chat-icon-view-chat-list]]
|
||||||
|
[status-im.models.commands :refer [parse-command-message-content]]
|
||||||
[status-im.chats-list.styles :as st]
|
[status-im.chats-list.styles :as st]
|
||||||
[status-im.utils.utils :refer [truncate-str]]
|
[status-im.utils.utils :refer [truncate-str]]
|
||||||
[status-im.i18n :refer [label label-pluralize]]
|
[status-im.i18n :refer [label label-pluralize]]
|
||||||
[status-im.utils.datetime :as time]
|
[status-im.utils.datetime :as time]
|
||||||
[status-im.utils.gfycat.core :refer [generate-gfy]]
|
[status-im.utils.gfycat.core :refer [generate-gfy]]
|
||||||
[status-im.constants :refer [console-chat-id]]
|
[status-im.constants :refer [console-chat-id
|
||||||
[clojure.string :as str]))
|
content-type-command
|
||||||
|
content-type-command-request]]
|
||||||
|
[taoensso.timbre :as log]))
|
||||||
|
|
||||||
(defn message-content [{:keys [content] :as message}]
|
(defmulti message-content (fn [{:keys [content-type] :as message}] content-type))
|
||||||
(let [content (if message
|
|
||||||
(if (string? content)
|
(defmethod message-content content-type-command
|
||||||
content
|
[{{:keys [command params]} :content}]
|
||||||
(:content content)))]
|
(let [kw (keyword (str "t/command-text-" (name command)))]
|
||||||
|
(label kw params)))
|
||||||
|
|
||||||
|
(defmethod message-content content-type-command-request
|
||||||
|
[{{:keys [content]} :content}]
|
||||||
|
content)
|
||||||
|
|
||||||
|
(defmethod message-content :default
|
||||||
|
[{:keys [content]}]
|
||||||
|
content)
|
||||||
|
|
||||||
|
(defn message-content-text [message]
|
||||||
|
(let [content (message-content message)]
|
||||||
(if (str/blank? content)
|
(if (str/blank? content)
|
||||||
[text {:style st/last-message-text-no-messages}
|
[text {:style st/last-message-text-no-messages}
|
||||||
(label :t/no-messages)]
|
(label :t/no-messages)]
|
||||||
|
@ -71,7 +88,7 @@
|
||||||
(when group-chat
|
(when group-chat
|
||||||
[text {:style st/memebers-text}
|
[text {:style st/memebers-text}
|
||||||
(label-pluralize (inc (count contacts)) :t/members)])]
|
(label-pluralize (inc (count contacts)) :t/members)])]
|
||||||
[message-content last-message]]
|
[message-content-text last-message]]
|
||||||
[view
|
[view
|
||||||
(when last-message
|
(when last-message
|
||||||
[view st/status-container
|
[view st/status-container
|
||||||
|
|
|
@ -65,7 +65,9 @@
|
||||||
|
|
||||||
(defn get-last-message
|
(defn get-last-message
|
||||||
[chat-id]
|
[chat-id]
|
||||||
(data-store/get-last-message chat-id))
|
(let [{:keys [content-type] :as message} (data-store/get-last-message chat-id)]
|
||||||
|
(when (and message (command-type? content-type))
|
||||||
|
(clojure.core/update message :content str-to-map))))
|
||||||
|
|
||||||
(defn get-unviewed
|
(defn get-unviewed
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -31,8 +31,7 @@
|
||||||
[chat-id]
|
[chat-id]
|
||||||
(-> (realm/get-by-field @realm/account-realm :message :chat-id chat-id)
|
(-> (realm/get-by-field @realm/account-realm :message :chat-id chat-id)
|
||||||
(realm/sorted :timestamp :desc)
|
(realm/sorted :timestamp :desc)
|
||||||
(realm/single)
|
(realm/single-cljs)))
|
||||||
(js->clj :keywordize-keys true)))
|
|
||||||
|
|
||||||
(defn get-unviewed
|
(defn get-unviewed
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -139,6 +139,9 @@
|
||||||
:keypair-password-command-description ""
|
:keypair-password-command-description ""
|
||||||
:help-command-description "Help"
|
:help-command-description "Help"
|
||||||
:request "Request"
|
:request "Request"
|
||||||
|
:command-text-location "Location: {{address}}"
|
||||||
|
:command-text-browse "Browsing webpage: {{webpage}}"
|
||||||
|
:command-text-send "Transaction: {{amount}} ETH"
|
||||||
|
|
||||||
;new-group
|
;new-group
|
||||||
:group-chat-name "Chat name"
|
:group-chat-name "Chat name"
|
||||||
|
|
Loading…
Reference in New Issue