Merge pull request #569 from status-im/feature/#562

Staging area disabled (#562)
This commit is contained in:
Roman Volosovskyi 2016-12-21 17:06:20 +02:00 committed by GitHub
commit 4a54a2fe24
15 changed files with 21 additions and 165 deletions

View File

@ -203,24 +203,6 @@
(dispatch [:set-chat-command command type]) (dispatch [:set-chat-command command type])
(dispatch [:set-chat-command-content text])))) (dispatch [:set-chat-command-content text]))))
(register-handler :set-staged-commands-scroll-view
(fn [{:keys [current-chat-id] :as db} [_ view]]
(assoc-in db [:chats current-chat-id :staged-scroll-view] view)))
(register-handler :set-staged-commands-scroll-height
(fn [{:keys [current-chat-id] :as db} [_ height]]
(assoc-in db [:chats current-chat-id :staged-scroll-height] height)))
(register-handler :staged-commands-scroll-to
(u/side-effect!
(fn [{:keys [current-chat-id chats]} [_ height]]
(let [{:keys [staged-scroll-view staged-scroll-height]} (get chats current-chat-id)]
(when staged-scroll-view
(let [y (if (< 0 staged-scroll-height height)
(- height staged-scroll-height)
0)]
(.scrollTo staged-scroll-view (clj->js {:x 0 :y y}))))))))
(register-handler :set-message-input-view-height (register-handler :set-message-input-view-height
(fn [{:keys [current-chat-id] :as db} [_ height]] (fn [{:keys [current-chat-id] :as db} [_ height]]
(assoc-in db [:chats current-chat-id :message-input-height] height))) (assoc-in db [:chats current-chat-id :message-input-height] height)))

View File

@ -90,7 +90,8 @@
(status/call-jail chat-id (status/call-jail chat-id
path path
params params
#(dispatch [:command-preview chat-id id %]))))) #(do (dispatch [:command-preview chat-id id %])
(dispatch [:send-chat-message]))))))
(defn command-input (defn command-input
([{:keys [current-chat-id] :as db}] ([{:keys [current-chat-id] :as db}]

View File

@ -182,7 +182,7 @@
(register-handler ::prepare-message (register-handler ::prepare-message
(u/side-effect! (u/side-effect!
(fn [{:keys [network-status]} [_ {:keys [chat-id identity message] :as params}]] (fn [{:keys [network-status] :as db} [_ {:keys [chat-id identity message] :as params}]]
(let [{:keys [group-chat]} (get-in db [:chats chat-id]) (let [{:keys [group-chat]} (get-in db [:chats chat-id])
clock-value (messages/get-last-clock-value chat-id) clock-value (messages/get-last-clock-value chat-id)
message' (cu/check-author-direction message' (cu/check-author-direction

View File

@ -23,7 +23,6 @@
[status-im.chat.views.datemark :refer [chat-datemark]] [status-im.chat.views.datemark :refer [chat-datemark]]
[status-im.chat.views.response :refer [response-view]] [status-im.chat.views.response :refer [response-view]]
[status-im.chat.views.new-message :refer [chat-message-input-view]] [status-im.chat.views.new-message :refer [chat-message-input-view]]
[status-im.chat.views.staged-commands :refer [staged-commands-view]]
[status-im.chat.views.actions :refer [actions-view]] [status-im.chat.views.actions :refer [actions-view]]
[status-im.chat.views.emoji :refer [emoji-view]] [status-im.chat.views.emoji :refer [emoji-view]]
[status-im.chat.views.bottom-info :refer [bottom-info-view]] [status-im.chat.views.bottom-info :refer [bottom-info-view]]
@ -173,7 +172,6 @@
(defview messages-container [messages] (defview messages-container [messages]
[offset [:messages-offset] [offset [:messages-offset]
staged-scroll-height [:get-chat-staged-commands-scroll-height]
messages-offset (anim/create-value 0) messages-offset (anim/create-value 0)
context {:offset offset context {:offset offset
:val messages-offset} :val messages-offset}
@ -181,7 +179,7 @@
{:component-did-mount on-update {:component-did-mount on-update
:component-did-update on-update} :component-did-update on-update}
[animated-view [animated-view
{:style (st/messages-container staged-scroll-height messages-offset)} {:style (st/messages-container messages-offset)}
messages]) messages])
(defview chat [] (defview chat []
@ -190,7 +188,6 @@
show-bottom-info? [:chat-ui-props :show-bottom-info?] show-bottom-info? [:chat-ui-props :show-bottom-info?]
show-emoji? [:chat-ui-props :show-emoji?] show-emoji? [:chat-ui-props :show-emoji?]
command? [:command?] command? [:command?]
staged-commands [:get-chat-staged-commands]
layout-height [:get :layout-height]] layout-height [:get :layout-height]]
{:component-did-mount #(dispatch [:check-autorun])} {:component-did-mount #(dispatch [:check-autorun])}
[view {:style st/chat-view [view {:style st/chat-view
@ -203,8 +200,6 @@
[messages-view group-chat]] [messages-view group-chat]]
;; todo uncomment this ;; todo uncomment this
#_(when @group-chat [typing-all]) #_(when @group-chat [typing-all])
(when (seq staged-commands)
[staged-commands-view staged-commands])
(when-not command? (when-not command?
[suggestion-container]) [suggestion-container])
[response-view] [response-view]
@ -215,4 +210,5 @@
[actions-view]) [actions-view])
(when show-bottom-info? (when show-bottom-info?
[bottom-info-view]) [bottom-info-view])
[offline-view {:top (get-in platform-specific [:component-styles :status-bar :default :height])}]]) [offline-view {:top (get-in platform-specific
[:component-styles :status-bar :default :height])}]])

View File

@ -70,54 +70,3 @@
:width 12 :width 12
:height 12}) :height 12})
(defn staged-commands [message-input-height input-margin]
{:position :absolute
:background-color color-white
:bottom (+ message-input-height input-margin)
:left 0
:right 0
:max-height 150
:elevation 5})
(def staged-command-container
{:flex 1
:alignItems :flex-start
:flexDirection :column
:backgroundColor color-white})
(def staged-command-background
{:flexDirection :column
:margin-top 16
:margin-left 16
:margin-right 0
:padding-bottom 12
:padding-left 12
:backgroundColor chat-background
:borderRadius 14})
(def staged-command-header
{:flex-direction :row
:justify-content :space-between})
(def staged-command-info-container
{:flexDirection :row
:margin-top 12})
(def staged-command-cancel
{:padding-left 12
:padding-top 16
:padding-right 12})
(def staged-command-cancel-icon
{:width 16
:height 16})
(def staged-command-content
{:marginTop 5
:marginHorizontal 0
:fontSize 14
:color color-black})
(def staged-commands-bottom
{:height 16
:background-color "white"})

View File

@ -49,10 +49,10 @@
:opacity 0.69 :opacity 0.69
:color color-white}) :color color-white})
(defn response-view [height input-margin staged-commands] (defn response-view [height input-margin]
{:flexDirection :column {:flexDirection :column
:position :absolute :position :absolute
:elevation (if (seq staged-commands) 5 4) :elevation 4
:left 0 :left 0
:right 0 :right 0
:bottom input-margin :bottom input-margin

View File

@ -16,10 +16,10 @@
(def toolbar-container (def toolbar-container
{}) {})
(defn messages-container [staged-height bottom] (defn messages-container [bottom]
{:flex 1 {:flex 1
:padding-bottom bottom :padding-bottom bottom
:margin-bottom staged-height}) :margin-bottom 0})
(def toolbar-view (def toolbar-view
{:flexDirection :row {:flexDirection :row

View File

@ -67,7 +67,7 @@
:fontSize 12 :fontSize 12
:color text2-color}) :color text2-color})
(defn container [height input-margin staged-commands] (defn container [height input-margin]
{:flexDirection :column {:flexDirection :column
:position :absolute :position :absolute
:left 0 :left 0
@ -75,7 +75,7 @@
:bottom input-margin :bottom input-margin
:height height :height height
:backgroundColor color-white :backgroundColor color-white
:elevation (if (seq staged-commands) 5 4)}) :elevation 4})
(def request-container (def request-container
{:height 56 {:height 56

View File

@ -89,13 +89,6 @@
(let [commands (subscribe [:get-chat-staged-commands])] (let [commands (subscribe [:get-chat-staged-commands])]
(reaction (some #(= id (:to-message %)) @commands))))) (reaction (some #(= id (:to-message %)) @commands)))))
(register-sub :get-chat-staged-commands-scroll-height
(fn [db _]
(let [{:keys [staged-commands
staged-scroll-height]} (get-in @db [:chats (:current-chat-id @db)])]
(reaction
(if (seq staged-commands) staged-scroll-height 0)))))
(register-sub :get-message-input-view-height (register-sub :get-message-input-view-height
(fn [db _] (fn [db _]
(reaction (get-in @db [:chats (:current-chat-id @db) :message-input-height])))) (reaction (get-in @db [:chats (:current-chat-id @db) :message-input-height]))))

View File

@ -5,7 +5,6 @@
[status-im.components.react :refer [view [status-im.components.react :refer [view
scroll-view]] scroll-view]]
[status-im.chat.views.message-input :refer [plain-message-input-view]] [status-im.chat.views.message-input :refer [plain-message-input-view]]
[status-im.chat.views.staged-commands :refer [simple-command-staged-view]]
[status-im.chat.constants :refer [input-height]] [status-im.chat.constants :refer [input-height]]
[status-im.utils.platform :refer [platform-specific]] [status-im.utils.platform :refer [platform-specific]]
[status-im.chat.styles.message :as st] [status-im.chat.styles.message :as st]
@ -34,13 +33,11 @@
parameter [:get-command-parameter] parameter [:get-command-parameter]
type [:command-type] type [:command-type]
suggestions [:get-suggestions] suggestions [:get-suggestions]
staged-commands [:get-chat-staged-commands]
message-input-height [:get-message-input-view-height]] message-input-height [:get-message-input-view-height]]
(let [on-top? (or (and (not (empty? suggestions)) (let [on-top? (or (and (not (empty? suggestions))
(not command?)) (not command?))
(not= response-height input-height)) (not= response-height input-height))
style (when-not (seq staged-commands) style (get-in platform-specific [:component-styles :chat :new-message])]
(get-in platform-specific [:component-styles :chat :new-message]))]
[view {:style (merge (st/new-message-container margin on-top?) style) [view {:style (merge (st/new-message-container margin on-top?) style)
:on-layout (fn [event] :on-layout (fn [event]
(let [height (get-height event)] (let [height (get-height event)]

View File

@ -94,7 +94,6 @@
input-margin (subscribe [:input-margin]) input-margin (subscribe [:input-margin])
changed (subscribe [:animations :response-height-changed]) changed (subscribe [:animations :response-height-changed])
animate? (subscribe [:animate?]) animate? (subscribe [:animate?])
staged-commands (subscribe [:get-chat-staged-commands])
context {:to-value to-response-height context {:to-value to-response-height
:val response-height :val response-height
:animate? animate?} :animate? animate?}
@ -109,8 +108,7 @@
@to-response-height @changed @to-response-height @changed
(into [animated-view {:style (st/response-view (into [animated-view {:style (st/response-view
response-height response-height
@input-margin @input-margin)}]
@staged-commands)}]
children))}))) children))})))
(defn on-navigation-change (defn on-navigation-change

View File

@ -1,61 +0,0 @@
(ns status-im.chat.views.staged-commands
(:require-macros [status-im.utils.views :refer [defview]])
(:require [re-frame.core :refer [subscribe dispatch]]
[status-im.components.react :refer [view
image
icon
text
touchable-highlight
scroll-view]]
[status-im.chat.styles.input :as st]
[status-im.chat.styles.command-pill :as pill-st]
[status-im.utils.platform :refer [platform-specific]]
[taoensso.timbre :as log]))
(defn cancel-command-input [staged-command]
(dispatch [:unstage-command staged-command]))
(defn get-height [event]
(.-height (.-layout (.-nativeEvent event))))
(defn simple-command-staged-view
[{:keys [command params] :as staged-command}]
(let [{:keys [type name]} command]
[view st/staged-command-container
[view st/staged-command-background
[view st/staged-command-header
[view st/staged-command-info-container
[view (pill-st/pill command)
[text {:style pill-st/pill-text}
(str
(if (= :command type) "!" "?")
name)]]]
[touchable-highlight {:style st/staged-command-cancel
:onPress #(cancel-command-input staged-command)}
[view [icon :close_small_gray
st/staged-command-cancel-icon]]]]
[view {:padding-right 12}
(if-let [preview (:preview staged-command)]
preview
[text {:style st/staged-command-content}
(if (= 1 (count params))
(first (vals params))
(str params))])]]]))
(defn staged-command-view [stage-command]
[simple-command-staged-view stage-command])
(defview staged-commands-view [staged-commands]
[message-input-height [:get-message-input-view-height]
input-margin [:input-margin]]
(let [style (when (seq staged-commands)
(get-in platform-specific [:component-styles :chat :new-message]))]
[view {:style (merge (st/staged-commands message-input-height input-margin)
style)}
[scroll-view {:bounces false
:ref #(dispatch [:set-staged-commands-scroll-view %])
:on-layout #(dispatch [:set-staged-commands-scroll-height (get-height %)])}
[view {:on-layout #(dispatch [:staged-commands-scroll-to (get-height %)])}
(for [command staged-commands]
^{:key command} [staged-command-view command])
[view st/staged-commands-bottom]]]]))

View File

@ -109,7 +109,6 @@
input-margin (subscribe [:input-margin]) input-margin (subscribe [:input-margin])
changed (subscribe [:animations :commands-height-changed]) changed (subscribe [:animations :commands-height-changed])
animate? (subscribe [:animate?]) animate? (subscribe [:animate?])
staged-commands (subscribe [:get-chat-staged-commands])
context {:to-value to-response-height context {:to-value to-response-height
:val h :val h
:animate? animate?} :animate? animate?}
@ -122,9 +121,9 @@
:reagent-render :reagent-render
(fn [h & elements] (fn [h & elements]
@to-response-height @changed @to-response-height @changed
(into [animated-view {:style (st/container h @input-margin @staged-commands)}] elements))}))) (into [animated-view {:style (st/container h @input-margin)}] elements))})))
(defview suggestion-container [any-staged-commands?] (defview suggestion-container []
(let [h (anim/create-value c/input-height)] (let [h (anim/create-value c/input-height)]
[container h [container h
[header h] [header h]

View File

@ -1,5 +1,6 @@
(ns status-im.data-store.discover (ns status-im.data-store.discover
(:require [status-im.data-store.realm.discover :as data-store])) (:require [status-im.data-store.realm.discover :as data-store])
(:refer-clojure :exclude [exists?]))
(defn get-all (defn get-all
[ordering] [ordering]

View File

@ -1,4 +1,5 @@
(ns status-im.protocol.message-cache) (ns status-im.protocol.message-cache
(:refer-clojure :exclude [exists?]))
(defonce messages-set (atom #{})) (defonce messages-set (atom #{}))
(defonce messages-map (atom {})) (defonce messages-map (atom {}))