browse from message bug

This commit is contained in:
Andrey Shovkoplyas 2017-10-23 11:40:36 +03:00 committed by Roman Volosovskyi
parent a8baf43681
commit 29030db2b6
3 changed files with 18 additions and 6 deletions

View File

@ -12,6 +12,7 @@
[status-im.data-store.chats :as chats-store] [status-im.data-store.chats :as chats-store]
[status-im.protocol.core :as protocol] [status-im.protocol.core :as protocol]
[status-im.constants :as const] [status-im.constants :as const]
[status-im.components.list-selection :as list-selection]
status-im.chat.events.input status-im.chat.events.input
status-im.chat.events.commands status-im.chat.events.commands
status-im.chat.events.animation status-im.chat.events.animation
@ -78,6 +79,11 @@
(fn [params] (fn [params]
(protocol/send-seen! params))) (protocol/send-seen! params)))
(re-frame/reg-fx
:browse
(fn [[command link]]
(list-selection/browse command link)))
;;;; Helper fns ;;;; Helper fns
(defn init-console-chat (defn init-console-chat
@ -251,3 +257,8 @@
{:db (assoc-in [:chats current-chat-id :messages] (get-stored-messages current-chat-id)) {:db (assoc-in [:chats current-chat-id :messages] (get-stored-messages current-chat-id))
;; TODO(janherich): make this dispatch into fn call once commands loading is refactored ;; TODO(janherich): make this dispatch into fn call once commands loading is refactored
:dispatch [:load-commands! current-chat-id]})))) :dispatch [:load-commands! current-chat-id]}))))
(handlers/register-handler-fx
:browse-link-from-message
(fn [{{:keys [global-commands]} :db} [_ link]]
{:browse [(:browse global-commands) link]}))

View File

@ -15,7 +15,7 @@
get-dimensions get-dimensions
dismiss-keyboard!]] dismiss-keyboard!]]
[status-im.components.animation :as anim] [status-im.components.animation :as anim]
[status-im.components.list-selection :refer [share browse share-or-open-map]] [status-im.components.list-selection :refer [share share-or-open-map]]
[status-im.chat.constants :as chat-consts] [status-im.chat.constants :as chat-consts]
[status-im.chat.models.commands :as commands] [status-im.chat.models.commands :as commands]
[status-im.chat.styles.message.message :as st] [status-im.chat.styles.message.message :as st]
@ -200,7 +200,7 @@
(if simple-text? (if simple-text?
[autolink {:style (st/text-message message) [autolink {:style (st/text-message message)
:text (apply str parsed-text) :text (apply str parsed-text)
:onPress #(browse %)}] :onPress #(dispatch [:browse-link-from-message %])}]
[text {:style (st/text-message message)} parsed-text]))]) [text {:style (st/text-message message)} parsed-text]))])
(defmulti message-content (fn [_ message _] (message :content-type))) (defmulti message-content (fn [_ message _] (message :content-type)))

View File

@ -28,7 +28,7 @@
:default)) :default))
:cancel-text (label :t/sharing-cancel)}))) :cancel-text (label :t/sharing-cancel)})))
(defn browse [link] (defn browse [command link]
(let [list-selection-fn (:list-selection-fn platform-specific)] (let [list-selection-fn (:list-selection-fn platform-specific)]
(list-selection-fn {:title (label :t/browsing-title) (list-selection-fn {:title (label :t/browsing-title)
:options [{:text (label :t/browsing-browse)} :options [{:text (label :t/browsing-browse)}
@ -37,9 +37,10 @@
(case index (case index
0 (do 0 (do
(dispatch [:select-chat-input-command (dispatch [:select-chat-input-command
{:bot "browse" (assoc (first command) :prefill [link])
:prefill [link]}]) nil
(js/setTimeout #(dispatch [:send-current-message]) 500)) true])
(js/setTimeout #(dispatch [:send-current-message]) 100))
1 (.openURL linking link) 1 (.openURL linking link)
:default)) :default))
:cancel-text (label :t/browsing-cancel)}))) :cancel-text (label :t/browsing-cancel)})))