Various !browse command issues on open (#349)

This commit is contained in:
Alexander Pantyuhov 2016-10-18 14:01:22 +03:00
parent d188b59803
commit 312a3d994c
11 changed files with 40 additions and 33 deletions

View File

@ -5,8 +5,8 @@ function wallet() {
} }
status.command({ status.command({
name: "wallet", name: "browse",
description: "wallet", description: "Browse wallet",
color: "#ffa500", color: "#ffa500",
fullscreen: true, fullscreen: true,
suggestionsTrigger: 'on-send', suggestionsTrigger: 'on-send',
@ -17,4 +17,4 @@ status.command({
}] }]
}); });
status.autorun("wallet"); status.autorun("browse");

View File

@ -13,7 +13,8 @@
[status-im.constants :refer [text-content-type [status-im.constants :refer [text-content-type
content-type-command content-type-command
content-type-command-request content-type-command-request
default-number-of-messages]] default-number-of-messages
wallet-chat-id]]
[status-im.utils.random :as random] [status-im.utils.random :as random]
[status-im.chat.sign-up :as sign-up-service] [status-im.chat.sign-up :as sign-up-service]
[status-im.navigation.handlers :as nav] [status-im.navigation.handlers :as nav]
@ -275,6 +276,8 @@
(let [chat-id (or id current-chat-id) (let [chat-id (or id current-chat-id)
messages (get-in db [:chats chat-id :messages]) messages (get-in db [:chats chat-id :messages])
db' (assoc db :current-chat-id chat-id)] 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-requests! chat-id])
(dispatch [:load-commands! chat-id]) (dispatch [:load-commands! chat-id])
(if (and (seq messages) (if (and (seq messages)

View File

@ -59,13 +59,13 @@
;[(after #(dispatch [:command-edit-mode]))] ;[(after #(dispatch [:command-edit-mode]))]
(fn [{:keys [current-chat-id] :as db}] (fn [{:keys [current-chat-id] :as db}]
(let [suggestions? (get-in db [:has-suggestions? current-chat-id]) (let [suggestions? (get-in db [:has-suggestions? current-chat-id])
fullscreen? (get-in db [:chats current-chat-id :command-input :command :fullscreen]) fullscreen? (get-in db [:chats current-chat-id :command-input :command :fullscreen])
max-height (get-in db [:layout-height]) max-height (get-in db [:layout-height])
height (if suggestions? height (if suggestions?
(if fullscreen? (if fullscreen?
max-height max-height
middle-height) middle-height)
(get-minimum-height db))] (get-minimum-height db))]
(assoc-in db [:animations :to-response-height current-chat-id] height)))) (assoc-in db [:animations :to-response-height current-chat-id] height))))
(defn fix-height (defn fix-height

View File

@ -17,6 +17,6 @@
(dispatch [:add-chat (dispatch [:add-chat
wallet-chat-id wallet-chat-id
{:name "Wallet" {:name "Wallet"
:dapp-url "http://127.0.0.1:3450"}]) :dapp-url "http://192.168.1.125:3450"}])
(dispatch [:add-contacts [dapp-contact]]))))) (dispatch [:add-contacts [dapp-contact]])))))

View File

@ -2,10 +2,10 @@
(:require [status-im.components.styles :refer [color-white]])) (:require [status-im.components.styles :refer [color-white]]))
(def drag-down-touchable (def drag-down-touchable
{:height 22 {:height 22
:background-color color-white :background-color color-white
:alignItems :center :alignItems :center
:justifyContent :center}) :justifyContent :center})
(def drag-down-icon (def drag-down-icon
{:width 16 {:width 16

View File

@ -7,7 +7,8 @@
color-black]] color-black]]
[status-im.chat.constants :refer [input-height [status-im.chat.constants :refer [input-height
request-info-height request-info-height
response-height-normal]])) response-height-normal]]
[status-im.utils.platform :as p]))
(def drag-container (def drag-container
{:height 16 {:height 16
@ -83,9 +84,9 @@
:height 12}) :height 12})
(defn command-input [ml disable?] (defn command-input [ml disable?]
{:flex 1 {:flex 1
:marginRight 16 :margin-right 16
:margin-left (- ml 5) :margin-left (- ml 5)
:padding 0 :padding 0
:fontSize 14 :font-size 14
:color (if disable? color-white text1-color)}) :color (if disable? color-white text1-color)})

View File

@ -9,7 +9,8 @@
[status-im.chat.views.plain-message :as plain-message] [status-im.chat.views.plain-message :as plain-message]
[status-im.chat.views.command :as command] [status-im.chat.views.command :as command]
[status-im.constants :refer [content-type-status]] [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 (register-sub :chat-properties
(fn [db [_ properties]] (fn [db [_ properties]]
@ -214,10 +215,12 @@
(get-in @db [:animations :command-suggestions-height @chat-id]))))) (get-in @db [:animations :command-suggestions-height @chat-id])))))
(register-sub :response-height (register-sub :response-height
(fn [db] (fn [db [_ status-bar]]
(let [chat-id (subscribe [:get-current-chat-id])] (let [chat-id (subscribe [:get-current-chat-id])]
(reaction (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 (register-sub :web-view-url
(fn [db] (fn [db]

View File

@ -63,7 +63,7 @@
disable? [:get :disable-input]] disable? [:get :disable-input]]
[text-input (merge [text-input (merge
(command-input-options command icon-width disable?) (command-input-options command icon-width disable?)
{:auto-focus true {:auto-focus false
:blur-on-submit false :blur-on-submit false
:accessibility-label :input :accessibility-label :input
:on-focus #(dispatch [:set :focused true]) :on-focus #(dispatch [:set :focused true])

View File

@ -76,13 +76,14 @@
(when-let [to-value @to-value] (when-let [to-value @to-value]
(when-not (= to-value (.-_value val)) (when-not (= to-value (.-_value val))
(if (or (nil? @animate?) @animate?) (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))))) (anim/set-value val to-value)))))
(defn container [response-height & children] (defn container [response-height & children]
(let [;; todo to-response-height, cur-response-height must be specific (let [;; todo to-response-height, cur-response-height must be specific
;; for each chat ;; for each chat
to-response-height (subscribe [:response-height]) to-response-height (subscribe [:response-height :default])
changed (subscribe [:animations :response-height-changed]) changed (subscribe [:animations :response-height-changed])
animate? (subscribe [:animate?]) animate? (subscribe [:animate?])
keyboard-height (subscribe [:get :keyboard-height]) keyboard-height (subscribe [:get :keyboard-height])
@ -120,7 +121,7 @@
:source {:uri url} :source {:uri url}
:java-script-enabled true :java-script-enabled true
:injected-java-script (slurp "resources/webview.js") :injected-java-script (slurp "resources/webview.js")
:style {:height 300} :bounces false
:on-navigation-state-change on-navigation-change}])) :on-navigation-state-change on-navigation-change}]))
(defview placeholder [] (defview placeholder []

View File

@ -91,10 +91,8 @@
(reg-handler :suggestions-handler (reg-handler :suggestions-handler
[(after #(dispatch [:animate-show-response])) [(after #(dispatch [:animate-show-response]))
(after (print-error-message! "Error on param suggestions")) (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 (= :on-send (keyword (:suggestions-trigger command)))
(when (:webViewUrl result)
(dispatch [:set-soft-input-mode :pan]))
(r/dismiss-keyboard!))))] (r/dismiss-keyboard!))))]
suggestions-handler!) suggestions-handler!)
(reg-handler :suggestions-event! (u/side-effect! suggestions-events-handler!)) (reg-handler :suggestions-event! (u/side-effect! suggestions-events-handler!))

View File

@ -1,6 +1,7 @@
(ns status-im.models.commands (ns status-im.models.commands
(:require [status-im.db :as db] (: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}] (defn get-commands [{:keys [current-chat-id] :as db}]
(or (get-in db [:chats current-chat-id :commands]) {})) (or (get-in db [:chats current-chat-id :commands]) {}))