Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cammellos committed May 18, 2022
1 parent b98f35b commit 9ae2498
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 417 deletions.
19 changes: 9 additions & 10 deletions src/status_im/chat/models/input.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,14 @@
{:events [:chat.ui/send-contact-request]}
[{:keys [db] :as cofx}]
(let [current-chat-id (:current-chat-id db)]
(fx/merge cofx
{:db (-> db
(assoc-in [:chat/inputs current-chat-id :metadata :sending-contact-request]
current-chat-id)
(assoc-in [:chat/inputs current-chat-id :metadata :responding-to-message]
nil)
(assoc-in [:chat/inputs current-chat-id :metadata :editing-message] nil)
(update-in [:chat/inputs current-chat-id :metadata]
dissoc :sending-image))})))
{:db (-> db
(assoc-in [:chat/inputs current-chat-id :metadata :sending-contact-request]
current-chat-id)
(assoc-in [:chat/inputs current-chat-id :metadata :responding-to-message]
nil)
(assoc-in [:chat/inputs current-chat-id :metadata :editing-message] nil)
(update-in [:chat/inputs current-chat-id :metadata]
dissoc :sending-image))}))

(fx/defn cancel-message-reply
"Cancels stage message reply"
Expand Down Expand Up @@ -282,7 +281,7 @@
{:events [:contacts/send-contact-request]}
[{:keys [db] :as cofx} public-key message]
(fx/merge cofx
{::json-rpc/call [{:method (json-rpc/call-ext-method "sendContactRequest")
{::json-rpc/call [{:method "wakuext_sendContactRequest"
:js-response true
:params [{:id public-key :message message}]
:on-error #(log/warn "failed to send a contact request" %)
Expand Down
6 changes: 3 additions & 3 deletions src/status_im/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
(def ^:const timeline-chat-type 5)
(def ^:const community-chat-type 6)

(def ^:const contact-request-state-pending 1)
(def ^:const contact-request-state-accepted 2)
(def ^:const contact-request-state-declined 3)
(def ^:const contact-request-message-state-pending 1)
(def ^:const contact-request-message-state-accepted 2)
(def ^:const contact-request-message-state-declined 3)

(def request-to-join-pending-state 1)

Expand Down
7 changes: 7 additions & 0 deletions src/status_im/contact/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
(when (> (count events) 1)
{:dispatch-n events}))))

(defn- own-info
[db]
(let [{:keys [name preferred-name identicon address]} (:multiaccount db)]
{:name (or preferred-name name)
:profile-image identicon
:address address}))

(fx/defn send-contact-request
{:events [::send-contact-request]}
[{:keys [db] :as cofx} public-key]
Expand Down
24 changes: 12 additions & 12 deletions src/status_im/ui/screens/chat/components/contact_request.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[status-im.ethereum.stateofus :as stateofus]
[status-im.ui.screens.chat.components.style :as styles]
[re-frame.core :as re-frame]
[clojure.string :as string]))
[clojure.string :as string])
(:require-macros [status-im.utils.views :refer [defview letsubs]]))

(def ^:private contact-request-symbol "")

Expand Down Expand Up @@ -49,18 +50,18 @@
(let [{:keys [input-text]} @(re-frame/subscribe [:chats/current-chat-inputs])]
[rn/view {:style {:flex-direction :row}}
[rn/view {:style (styles/contact-request-content)}
[quo/button {:type :secondary
[quo/button {:type :secondary
:weight :medium
:number-of-lines 1
:style {:line-height 18}
:on-press #(re-frame/dispatch [:chat.ui/cancel-contact-request])}
:on-press #(re-frame/dispatch [:chat.ui/cancel-contact-request])}
(i18n/label :t/cancel)]
[quo/button {:type :secondary
:disabled (string/blank? input-text)
:weight :medium
:after :main-icons/send
:after :main-icons/send
:on-press #(re-frame/dispatch [:contacts/send-contact-request their-public-key input-text])
:style {:line-height 18}}
:style {:line-height 18}}
(i18n/label :t/send-request)]]]))

(defn focus-input-on-contact-request [contact-request had-contact-request text-input-ref]
Expand All @@ -77,10 +78,9 @@
:padding-vertical 8}}
[contact-request-message contact-request]])

(defn contact-request-message-auto-focus-wrapper [text-input-ref]
(let [had-reply (atom nil)]
(fn []
(let [contact-request @(re-frame/subscribe [:chats/sending-contact-request])]
(focus-input-on-contact-request contact-request had-reply text-input-ref)
(when contact-request
[contact-request-message-wrapper contact-request])))))
(defview contact-request-message-auto-focus-wrapper [text-input-ref]
(letsubs [had-reply (atom nil)
contact-request @(re-frame/subscribe [:chats/sending-contact-request])]
{:component-did-mount #(focus-input-on-contact-request contact-request had-reply text-input-ref)}
(when contact-request
[contact-request-message-wrapper contact-request])))
2 changes: 1 addition & 1 deletion src/status_im/ui/screens/chat/components/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(defn input-container [contact-request]
{:background-color (:ui-01 @colors/theme)
:flex 1
:height (when contact-request 44)
:height (when contact-request 44)
:border-top-left-radius (if contact-request 8 16)
:border-top-right-radius (if contact-request 8 16)
:border-bottom-right-radius (if contact-request 8 4)
Expand Down
36 changes: 6 additions & 30 deletions src/status_im/ui/screens/chat/message/message.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -642,42 +642,18 @@
(i18n/label :t/contact-request-declined)])

(defn contact-request-status-label [state]
[react/view {:style {:width 136
:border-radius 8
:flex 1
:justify-content :center
:align-items :center
:background-color (when (= :retry state)
colors/blue-light)
:border-width 1
:border-color (case state
constants/contact-request-state-accepted colors/green-transparent-10
constants/contact-request-state-declined colors/red-light
constants/contact-request-state-pending colors/gray-lighter)
:padding-vertical 10
:padding-horizontal 16}}

[react/view {:style (style/contact-request-status-label state)}
(case state
constants/contact-request-state-pending [contact-request-status-pending]
constants/contact-request-state-accepted [contact-request-status-accepted]
constants/contact-request-state-declined [contact-request-status-declined])])
constants/contact-request-message-state-pending [contact-request-status-pending]
constants/contact-request-message-state-accepted [contact-request-status-accepted]
constants/contact-request-message-state-declined [contact-request-status-declined])])

(defmethod ->message constants/content-type-contact-request
[{:keys [outgoing] :as message} _]
[react/view {:style {:width 168
:min-height 224.71
:border-radius 8
:border-width 1
:border-color colors/gray-lighter
:align-items :center
:padding-bottom 10
:margin-vertical 4
:align-self (if outgoing :flex-end :flex-start)
:margin-right (if outgoing 8 0)
:margin-left (if outgoing 0 8)}}
[react/view {:style (style/content-type-contact-request outgoing)}
[react/image {:source (resources/get-image :hand-wave)
:style {:width 112
:height 96.71}}]
:height 97}}]
[quo/text {:style {:margin-top 6}
:weight :bold
:size :large}
Expand Down
7 changes: 7 additions & 0 deletions src/status_im/ui/screens/chat/styles/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,10 @@
{:font-size 13
:line-height 18
:text-align :center})

(def contact-request
{:width "100%"
:justify-content :center
:align-items :center
:border-top-width 1
:border-color colors/gray-transparent-10})
29 changes: 29 additions & 0 deletions src/status_im/ui/screens/chat/styles/message/message.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,32 @@
:border-bottom-left-radius 10
:border-bottom-right-radius 10
:border-color colors/gray-lighter})

(defn contact-request-status-label [state]
{:width 136
:border-radius 8
:flex 1
:justify-content :center
:align-items :center
:background-color (when (= :retry state)
colors/blue-light)
:border-width 1
:border-color (case state
constants/contact-request-message-state-accepted colors/green-transparent-10
constants/contact-request-message-state-declined colors/red-light
constants/contact-request-message-state-pending colors/gray-lighter)
:padding-vertical 10
:padding-horizontal 16})

(defn content-type-contact-request [outgoing]
{:width 168
:min-height 224.71
:border-radius 8
:border-width 1
:border-color colors/gray-lighter
:align-items :center
:padding-bottom 10
:margin-vertical 4
:align-self (if outgoing :flex-end :flex-start)
:margin-right (if outgoing 8 0)
:margin-left (if outgoing 0 8)})
6 changes: 1 addition & 5 deletions src/status_im/ui/screens/chat/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@

(defn contact-request []
(let [contact-request @(re-frame/subscribe [:chats/sending-contact-request])]
[react/view {:style {:width "100%"
:justify-content :center
:align-items :center
:border-top-width 1
:border-color colors/gray-transparent-10}}
[react/view {:style style/contact-request}
[react/image {:source (resources/get-image :hand-wave)
:style {:width 112
:height 96.71
Expand Down
66 changes: 0 additions & 66 deletions src/status_im/ui/screens/contact_requests/styles.cljs

This file was deleted.

0 comments on commit 9ae2498

Please sign in to comment.