From 8652f899e02f3962dd61ed202a0eeab018b9b90d Mon Sep 17 00:00:00 2001 From: Gheorghe Pinzaru Date: Mon, 27 Jul 2020 10:38:24 +0300 Subject: [PATCH] [#10988] Add entry point to start new chat from search results Fixes #10988 Allow public key and filter public chats Make toolbar width 100 Clear new identity from search QA issues fix Signed-off-by: Gheorghe Pinzaru --- resources/images/icons/private_chat@2x.png | Bin 0 -> 546 bytes resources/images/icons/private_chat@3x.png | Bin 0 -> 909 bytes src/status_im/ui/components/toolbar.cljs | 1 + .../ui/screens/add_new/new_chat/events.cljs | 8 +-- src/status_im/ui/screens/home/views.cljs | 61 ++++++++++++++---- translations/en.json | 3 + 6 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 resources/images/icons/private_chat@2x.png create mode 100644 resources/images/icons/private_chat@3x.png diff --git a/resources/images/icons/private_chat@2x.png b/resources/images/icons/private_chat@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..b9124a5a478ed3734855e4ed599079164458ac6e GIT binary patch literal 546 zcmV+-0^R+IP)|U4%i{&ebixykUuu5@iy2alRN<yHa9FV9te2VTF+$K<|RLlqrjg=bAqj8fV2o4D4 zeBb=NcS||H*S>FpFu%$he7spEc}(cZFBZWUeG04DO#%x3m@c4I!CJ~-x`2xcR{E9E zqz6oQ;~(r<;X+HkN?4=6a(rNbcA$VS!b-!qcLJa4cfgPIIZ{6|=cq3X2smEvBdPd{ zXPyqfi!3l73Xd2g%;%tVCoHv9VQ`y{`TW!1g!eF)Vw>;$6v5{mprg!)@=KbJ&g6~v ki2AYU2H!tJDwU_>2MrXsBEo5w<^TWy07*qoM6N<$f@i+%B>(^b literal 0 HcmV?d00001 diff --git a/resources/images/icons/private_chat@3x.png b/resources/images/icons/private_chat@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..12279c2f6d0028baa59288f891bef3f6dbe55a07 GIT binary patch literal 909 zcmV;819JR{P)8ux=R| zMJ=7zg7SuWE_uI28PaXOQP(h`uGx{P#~|bN!|P+>Gb^6Pi(lkH8f7!Kjp4k$QV~PC zOU+4tfgFgTY@!}lRN^F2sS<_>F<$qPy8I^Z%(*jTV~(R9Vu*VUb+YI)&IZHaHC4SR z*0mgZa8w+NEb-Vw6XGqQ7u`~bSRXg&V@`!eG!PB%HFCrDI27eA`M8LbeMcv&;CXbA z&S{`Cwky%2lbvU+oCY$%^8nrk$veOydxhy z|IZF~{WDjVa39_?WHCi!F^^;uXB5P7c&@mV92H1q5w%FVTD3H*V9;qKF^r>9dNqb6 zK5LXT$bw;_5RXw~m`0<~Xf%!knL1?(m8n#w)UowW2}wv{QNl|Lz?xc6d7J4AIt>#V zsY+mYjc&s{mm?FqraP_^FWnq~dZbPs+IU?CWoHz`5^p6<3&0uM^(%rQzB<20*Pgp$ zA_KkD#iVPQpiH{cC-iRX6vLo!8Xdtgkq4!=eY!}QBoiqEg@?bj9!3ztx@OyI+Gp!otM_zlcd?#Kqztt4DXhv|M#_qem0^H5 zM<0fG5L<*9+e-^=UKES+ErqyZ!c}qxB+8Ekvc-rUxRz%_ePYHb>OC7A@jhO&tBo1w zh6=>IsMcz}WBjh`f{Kk68;drTvP@sGj`StqNf*$&UdeQ%?|JqNX^=nU;RC~$P91<^ z{m#!QSwK4u%M<68j5+FpSBs9T-5rWC#B;z?Yfgn}{E%zmhM^_Tc^WTrvEu16jARjH jZMCG)Xfzs)#vc3wGKLv}&UFj#00000NkvXXu0mjfi=~a= literal 0 HcmV?d00001 diff --git a/src/status_im/ui/components/toolbar.cljs b/src/status_im/ui/components/toolbar.cljs index fbe4e21d48..3222c0275f 100644 --- a/src/status_im/ui/components/toolbar.cljs +++ b/src/status_im/ui/components/toolbar.cljs @@ -6,6 +6,7 @@ :or {size :default}}] (merge {:align-items :center :padding-horizontal 8 + :width "100%" :flex-direction :row :justify-content :space-between} (when center? diff --git a/src/status_im/ui/screens/add_new/new_chat/events.cljs b/src/status_im/ui/screens/add_new/new_chat/events.cljs index 27de3f18c5..ab6891e7cd 100644 --- a/src/status_im/ui/screens/add_new/new_chat/events.cljs +++ b/src/status_im/ui/screens/add_new/new_chat/events.cljs @@ -67,10 +67,10 @@ new-identity @resolve-last-id])}}))))))) -(handlers/register-handler-fx - ::new-chat-focus - (fn [{:keys [db]}] - {:db (dissoc db :contacts/new-identity)})) +(fx/defn clear-new-identity + {:events [::clear-new-identity ::new-chat-focus]} + [{:keys [db]}] + {:db (dissoc db :contacts/new-identity)}) (defn- get-validation-label [value] (case value diff --git a/src/status_im/ui/screens/home/views.cljs b/src/status_im/ui/screens/home/views.cljs index 43c907e691..d991fe0c91 100644 --- a/src/status_im/ui/screens/home/views.cljs +++ b/src/status_im/ui/screens/home/views.cljs @@ -13,7 +13,11 @@ [status-im.ui.components.colors :as colors] [status-im.ui.screens.add-new.new-public-chat.view :as new-public-chat] [quo.core :as quo] + [status-im.ui.screens.add-new.new-chat.events :as new-chat] [status-im.ui.components.search-input.view :as search-input] + [status-im.ui.screens.add-new.new-public-chat.db :as db] + [status-im.utils.debounce :as debounce] + [status-im.utils.utils :as utils] [cljs-bean.core :as bean] [status-im.ui.components.topbar :as topbar]) (:require-macros [status-im.utils.views :as views])) @@ -90,13 +94,42 @@ {:search-active? search-active? :search-filter search-filter :on-cancel #(re-frame/dispatch [:search/home-filter-changed nil]) - :on-blur #(when-not (seq chats) - (re-frame/dispatch [:search/home-filter-changed nil])) + :on-blur (fn [] + (when-not (seq chats) + (re-frame/dispatch [:search/home-filter-changed nil])) + (re-frame/dispatch [::new-chat/clear-new-identity])) :on-focus (fn [search-filter] (when-not search-filter - (re-frame/dispatch [:search/home-filter-changed ""]))) + (re-frame/dispatch [:search/home-filter-changed ""]) + (re-frame/dispatch [::new-chat/clear-new-identity]))) :on-change (fn [text] - (re-frame/dispatch [:search/home-filter-changed text]))}]]) + (re-frame/dispatch [:search/home-filter-changed text]) + (re-frame/dispatch [:set-in [:contacts/new-identity :state] :searching]) + (debounce/debounce-and-dispatch [:new-chat/set-new-identity text] 300))}]]) + +(defn start-suggestion [search-value] + (let [{:keys [state ens-name public-key]} + @(re-frame/subscribe [:contacts/new-identity]) + valid-private? (= state :valid) + valid-public? (db/valid-topic? search-value)] + (when (or valid-public? valid-private?) + [react/view + [quo/list-header (i18n/label :t/search-no-chat-found)] + (when valid-private? + [quo/list-item {:theme :accent + :icon :main-icons/private-chat + :title (or ens-name (utils/get-shortened-address public-key)) + :subtitle (i18n/label :t/join-new-private-chat) + :on-press (fn [] + (debounce/dispatch-and-chill [:contact.ui/contact-code-submitted false] 3000))}]) + (when valid-public? + [quo/list-item {:theme :accent + :icon :main-icons/public-chat + :title (str "#" search-value) + :subtitle (i18n/label :t/join-new-public-chat) + :on-press (fn [] + (re-frame/dispatch [:chat.ui/start-public-chat search-value]) + (re-frame/dispatch [:set :public-group-topic nil]))}])]))) (views/defview chats-list [] (views/letsubs [loading? [:chats/loading?] @@ -111,15 +144,17 @@ (not @search-active?)) [welcome-blank-page] [list/flat-list - {:key-fn :chat-id - :keyboard-should-persist-taps :always - :data chats - :render-fn (fn [home-item] [inner-item/home-list-item home-item]) - :header (when (or (seq chats) @search-active?) - [search-input-wrapper search-filter chats]) - :footer (if (and (not hide-home-tooltip?) (not @search-active?)) - [home-tooltip-view] - [react/view {:height 68}])}])))) + {:key-fn :chat-id + :keyboard-should-persist-taps :always + :data chats + :render-fn (fn [home-item] [inner-item/home-list-item home-item]) + :header (when (or (seq chats) @search-active?) + [search-input-wrapper search-filter chats]) + :empty-component (when @search-active? + [start-suggestion search-filter]) + :footer (if (and (not hide-home-tooltip?) (not @search-active?)) + [home-tooltip-view] + [react/view {:height 68}])}])))) (views/defview plus-button [] (views/letsubs [logging-in? [:multiaccounts/login]] diff --git a/translations/en.json b/translations/en.json index 73ec0de129..e024dec673 100644 --- a/translations/en.json +++ b/translations/en.json @@ -816,6 +816,9 @@ "public-chats": "Public chats", "public-group-status": "Public", "public-group-topic": "Topic", + "join-new-public-chat": "Join a public chat", + "join-new-private-chat": "Start a new private chat", + "search-no-chat-found": "No search results. Do you mean", "public-key": "Public key", "puk-and-pairing-codes-displayed": "PUK and pairing codes displayed", "puk-code": "PUK code",