From 312a3d994c5cfe235b35397a3b2a8d34ba13cb80 Mon Sep 17 00:00:00 2001 From: Alexander Pantyuhov Date: Tue, 18 Oct 2016 14:01:22 +0300 Subject: [PATCH] Various !browse command issues on open (#349) --- resources/wallet.js | 6 +++--- src/status_im/chat/handlers.cljs | 5 ++++- src/status_im/chat/handlers/animation.cljs | 14 +++++++------- src/status_im/chat/handlers/wallet_chat.cljs | 2 +- src/status_im/chat/styles/dragdown.cljs | 6 +++--- src/status_im/chat/styles/response.cljs | 15 ++++++++------- src/status_im/chat/subs.cljs | 9 ++++++--- src/status_im/chat/views/message_input.cljs | 2 +- src/status_im/chat/views/response.cljs | 7 ++++--- src/status_im/commands/handlers/jail.cljs | 4 +--- src/status_im/models/commands.cljs | 3 ++- 11 files changed, 40 insertions(+), 33 deletions(-) diff --git a/resources/wallet.js b/resources/wallet.js index 23e6b739ee..740689f6a3 100644 --- a/resources/wallet.js +++ b/resources/wallet.js @@ -5,8 +5,8 @@ function wallet() { } status.command({ - name: "wallet", - description: "wallet", + name: "browse", + description: "Browse wallet", color: "#ffa500", fullscreen: true, suggestionsTrigger: 'on-send', @@ -17,4 +17,4 @@ status.command({ }] }); -status.autorun("wallet"); +status.autorun("browse"); diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index c8f6712d96..3321fec436 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -13,7 +13,8 @@ [status-im.constants :refer [text-content-type content-type-command content-type-command-request - default-number-of-messages]] + default-number-of-messages + wallet-chat-id]] [status-im.utils.random :as random] [status-im.chat.sign-up :as sign-up-service] [status-im.navigation.handlers :as nav] @@ -275,6 +276,8 @@ (let [chat-id (or id current-chat-id) messages (get-in db [:chats chat-id :messages]) db' (assoc db :current-chat-id chat-id)] + (when (= current-chat-id wallet-chat-id) + (dispatch [:cancel-command])) (dispatch [:load-requests! chat-id]) (dispatch [:load-commands! chat-id]) (if (and (seq messages) diff --git a/src/status_im/chat/handlers/animation.cljs b/src/status_im/chat/handlers/animation.cljs index 3022e84dfb..04f7cf4100 100644 --- a/src/status_im/chat/handlers/animation.cljs +++ b/src/status_im/chat/handlers/animation.cljs @@ -59,13 +59,13 @@ ;[(after #(dispatch [:command-edit-mode]))] (fn [{:keys [current-chat-id] :as db}] (let [suggestions? (get-in db [:has-suggestions? current-chat-id]) - fullscreen? (get-in db [:chats current-chat-id :command-input :command :fullscreen]) - max-height (get-in db [:layout-height]) - height (if suggestions? - (if fullscreen? - max-height - middle-height) - (get-minimum-height db))] + fullscreen? (get-in db [:chats current-chat-id :command-input :command :fullscreen]) + max-height (get-in db [:layout-height]) + height (if suggestions? + (if fullscreen? + max-height + middle-height) + (get-minimum-height db))] (assoc-in db [:animations :to-response-height current-chat-id] height)))) (defn fix-height diff --git a/src/status_im/chat/handlers/wallet_chat.cljs b/src/status_im/chat/handlers/wallet_chat.cljs index 3fe5718bbf..03bb50379b 100644 --- a/src/status_im/chat/handlers/wallet_chat.cljs +++ b/src/status_im/chat/handlers/wallet_chat.cljs @@ -17,6 +17,6 @@ (dispatch [:add-chat wallet-chat-id {:name "Wallet" - :dapp-url "http://127.0.0.1:3450"}]) + :dapp-url "http://192.168.1.125:3450"}]) (dispatch [:add-contacts [dapp-contact]]))))) diff --git a/src/status_im/chat/styles/dragdown.cljs b/src/status_im/chat/styles/dragdown.cljs index 7505021a6f..d4d974ac21 100644 --- a/src/status_im/chat/styles/dragdown.cljs +++ b/src/status_im/chat/styles/dragdown.cljs @@ -2,10 +2,10 @@ (:require [status-im.components.styles :refer [color-white]])) (def drag-down-touchable - {:height 22 + {:height 22 :background-color color-white - :alignItems :center - :justifyContent :center}) + :alignItems :center + :justifyContent :center}) (def drag-down-icon {:width 16 diff --git a/src/status_im/chat/styles/response.cljs b/src/status_im/chat/styles/response.cljs index e85d845f8e..f76a1b8135 100644 --- a/src/status_im/chat/styles/response.cljs +++ b/src/status_im/chat/styles/response.cljs @@ -7,7 +7,8 @@ color-black]] [status-im.chat.constants :refer [input-height request-info-height - response-height-normal]])) + response-height-normal]] + [status-im.utils.platform :as p])) (def drag-container {:height 16 @@ -83,9 +84,9 @@ :height 12}) (defn command-input [ml disable?] - {:flex 1 - :marginRight 16 - :margin-left (- ml 5) - :padding 0 - :fontSize 14 - :color (if disable? color-white text1-color)}) + {:flex 1 + :margin-right 16 + :margin-left (- ml 5) + :padding 0 + :font-size 14 + :color (if disable? color-white text1-color)}) diff --git a/src/status_im/chat/subs.cljs b/src/status_im/chat/subs.cljs index 575dead253..d280a60da7 100644 --- a/src/status_im/chat/subs.cljs +++ b/src/status_im/chat/subs.cljs @@ -9,7 +9,8 @@ [status-im.chat.views.plain-message :as plain-message] [status-im.chat.views.command :as command] [status-im.constants :refer [content-type-status]] - [status-im.utils.datetime :as time])) + [status-im.utils.datetime :as time] + [status-im.utils.platform :refer [platform-specific]])) (register-sub :chat-properties (fn [db [_ properties]] @@ -214,10 +215,12 @@ (get-in @db [:animations :command-suggestions-height @chat-id]))))) (register-sub :response-height - (fn [db] + (fn [db [_ status-bar]] (let [chat-id (subscribe [:get-current-chat-id])] (reaction - (get-in @db [:animations :to-response-height @chat-id]))))) + (min (get-in @db [:animations :to-response-height @chat-id]) + (- (:layout-height @db) + (get-in platform-specific [:component-styles :status-bar status-bar :height]))))))) (register-sub :web-view-url (fn [db] diff --git a/src/status_im/chat/views/message_input.cljs b/src/status_im/chat/views/message_input.cljs index 601573827f..422133b237 100644 --- a/src/status_im/chat/views/message_input.cljs +++ b/src/status_im/chat/views/message_input.cljs @@ -63,7 +63,7 @@ disable? [:get :disable-input]] [text-input (merge (command-input-options command icon-width disable?) - {:auto-focus true + {:auto-focus false :blur-on-submit false :accessibility-label :input :on-focus #(dispatch [:set :focused true]) diff --git a/src/status_im/chat/views/response.cljs b/src/status_im/chat/views/response.cljs index a33c16e8fc..7258861cab 100644 --- a/src/status_im/chat/views/response.cljs +++ b/src/status_im/chat/views/response.cljs @@ -76,13 +76,14 @@ (when-let [to-value @to-value] (when-not (= to-value (.-_value val)) (if (or (nil? @animate?) @animate?) - (anim/start (anim/spring val {:toValue to-value})) + (anim/start (anim/timing val {:toValue to-value + :duration 300})) (anim/set-value val to-value))))) (defn container [response-height & children] (let [;; todo to-response-height, cur-response-height must be specific ;; for each chat - to-response-height (subscribe [:response-height]) + to-response-height (subscribe [:response-height :default]) changed (subscribe [:animations :response-height-changed]) animate? (subscribe [:animate?]) keyboard-height (subscribe [:get :keyboard-height]) @@ -120,7 +121,7 @@ :source {:uri url} :java-script-enabled true :injected-java-script (slurp "resources/webview.js") - :style {:height 300} + :bounces false :on-navigation-state-change on-navigation-change}])) (defview placeholder [] diff --git a/src/status_im/commands/handlers/jail.cljs b/src/status_im/commands/handlers/jail.cljs index ea0fc85e43..401488e2b1 100644 --- a/src/status_im/commands/handlers/jail.cljs +++ b/src/status_im/commands/handlers/jail.cljs @@ -91,10 +91,8 @@ (reg-handler :suggestions-handler [(after #(dispatch [:animate-show-response])) (after (print-error-message! "Error on param suggestions")) - (after (fn [_ [{:keys [command]} {:keys [result]}]] + (after (fn [_ [{:keys [command]}]] (when (= :on-send (keyword (:suggestions-trigger command))) - (when (:webViewUrl result) - (dispatch [:set-soft-input-mode :pan])) (r/dismiss-keyboard!))))] suggestions-handler!) (reg-handler :suggestions-event! (u/side-effect! suggestions-events-handler!)) diff --git a/src/status_im/models/commands.cljs b/src/status_im/models/commands.cljs index 926365ea7c..9bc8b60632 100644 --- a/src/status_im/models/commands.cljs +++ b/src/status_im/models/commands.cljs @@ -1,6 +1,7 @@ (ns status-im.models.commands (:require [status-im.db :as db] - [tailrecursion.priority-map :refer [priority-map-by]])) + [tailrecursion.priority-map :refer [priority-map-by]] + [taoensso.timbre :as log])) (defn get-commands [{:keys [current-chat-id] :as db}] (or (get-in db [:chats current-chat-id :commands]) {}))