Skip to content

Commit 9c1bfa8

Browse files
committed
Now user profile can be opened from public chat
Signed-off-by: Volodymyr Kozieiev <[email protected]>
1 parent 9ceb02e commit 9c1bfa8

File tree

2 files changed

+55
-32
lines changed

2 files changed

+55
-32
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(ns status-im.ui.screens.desktop.main.chat.events
2+
(:require [re-frame.core :as re-frame]
3+
[status-im.ui.screens.navigation :as navigation]
4+
[status-im.utils.handlers :as handlers]
5+
[status-im.utils.handlers-macro :as handlers-macro]))
6+
7+
(defn show-profile-desktop [identity {:keys [db] :as cofx}]
8+
(handlers-macro/merge-fx
9+
cofx
10+
{:db (assoc db :contacts/identity identity)}
11+
(navigation/navigate-to-cofx :chat-profile nil)))
12+
13+
(handlers/register-handler-fx
14+
:show-profile-desktop
15+
[re-frame/trim-v]
16+
(fn [cofx [identity]]
17+
(show-profile-desktop identity cofx)))

src/status_im/ui/screens/desktop/main/chat/views.cljs

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
(ns status-im.ui.screens.desktop.main.chat.views
32
(:require-macros [status-im.utils.views :as views])
43
(:require [re-frame.core :as re-frame]
@@ -18,7 +17,9 @@
1817
[status-im.ui.screens.desktop.main.tabs.profile.views :as profile.views]
1918
[status-im.ui.components.icons.vector-icons :as vector-icons]
2019
[status-im.ui.screens.desktop.main.chat.styles :as styles]
21-
[status-im.i18n :as i18n]))
20+
[status-im.utils.contacts :as utils.contacts]
21+
[status-im.i18n :as i18n]
22+
[status-im.ui.screens.desktop.main.chat.events :as chat.events]))
2223

2324
(views/defview toolbar-chat-view [{:keys [chat-id color public-key public? group-chat]
2425
:as current-chat}]
@@ -47,7 +48,7 @@
4748
[react/view
4849
(when (and (not group-chat) (not public?))
4950
[react/text {:style (styles/profile-actions-text colors/black)
50-
:on-press #(re-frame/dispatch [:navigate-to :chat-profile])}
51+
:on-press #(re-frame/dispatch [:show-profile-desktop whisper-identity])}
5152
(i18n/label :t/view-profile)])
5253

5354
[react/text {:style (styles/profile-actions-text colors/red)
@@ -74,10 +75,11 @@
7475

7576
(views/defview member-photo [from]
7677
(letsubs [photo-path [:get-photo-path from]]
77-
[react/image {:source {:uri (if (string/blank? photo-path)
78-
(identicon/identicon from)
79-
photo-path)}
80-
:style styles/photo-style}]))
78+
[react/touchable-highlight {:on-press #(re-frame/dispatch [:show-profile-desktop from])}
79+
[react/image {:source {:uri (if (string/blank? photo-path)
80+
(identicon/identicon from)
81+
photo-path)}
82+
:style styles/photo-style}]]))
8183

8284
(views/defview my-photo [from]
8385
(views/letsubs [account [:get-current-account]]
@@ -213,31 +215,35 @@
213215
[chat-text-input]]))
214216

215217
(views/defview chat-profile []
216-
(views/letsubs [{:keys [pending? whisper-identity public-key] :as contact} [:get-current-chat-contact]]
217-
[react/view {:style styles/chat-profile-body}
218-
[profile.views/profile-badge contact]
218+
(letsubs [identity [:get-current-contact-identity]
219+
maybe-contact [:get-current-contact]]
220+
221+
(let [contact (or maybe-contact (utils.contacts/whisper-id->new-contact identity))
222+
{:keys [pending? whisper-identity public-key]} contact]
223+
[react/view {:style styles/chat-profile-body}
224+
[profile.views/profile-badge contact]
219225
;; for private chat, public key will be chat-id
220-
[react/view
221-
(if pending?
222-
[react/touchable-highlight {:on-press #(re-frame/dispatch [:add-contact whisper-identity])}
226+
[react/view
227+
(if (or (nil? pending?) pending?)
228+
[react/touchable-highlight {:on-press #(re-frame/dispatch [:add-contact whisper-identity])}
229+
[react/view {:style styles/chat-profile-row}
230+
[react/view {:style styles/chat-profile-icon-container
231+
:accessibility-label :add-contact-link}
232+
[vector-icons/icon :icons/add {:style (styles/chat-profile-icon colors/blue)}]]
233+
[react/text {:style (styles/contact-card-text colors/blue)} (i18n/label :t/add-to-contacts)]]]
234+
[react/view {:style styles/chat-profile-row}
235+
[react/view {:style styles/chat-profile-icon-container
236+
:accessibility-label :add-contact-link}
237+
[vector-icons/icon :icons/add {:style (styles/chat-profile-icon colors/gray)}]]
238+
[react/text {:style (styles/contact-card-text colors/gray)} (i18n/label :t/in-contacts)]])
239+
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to-chat public-key])}
223240
[react/view {:style styles/chat-profile-row}
224241
[react/view {:style styles/chat-profile-icon-container
225-
:accessibility-label :add-contact-link}
226-
[vector-icons/icon :icons/add {:style (styles/chat-profile-icon colors/blue)}]]
227-
[react/text {:style (styles/contact-card-text colors/blue)} (i18n/label :t/add-to-contacts)]]]
228-
[react/view {:style styles/chat-profile-row}
229-
[react/view {:style styles/chat-profile-icon-container
230-
:accessibility-label :add-contact-link}
231-
[vector-icons/icon :icons/add {:style (styles/chat-profile-icon colors/gray)}]]
232-
[react/text {:style (styles/contact-card-text colors/gray)} (i18n/label :t/in-contacts)]])
233-
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to-chat public-key])}
234-
[react/view {:style styles/chat-profile-row}
235-
[react/view {:style styles/chat-profile-icon-container
236-
:accessibility-label :send-message-link}
237-
[vector-icons/icon :icons/chats {:style (styles/chat-profile-icon colors/blue)}]]
238-
[react/text {:style (styles/contact-card-text colors/blue)}
239-
(i18n/label :t/send-message)]]]
240-
[react/text {:style styles/chat-profile-contact-code} (i18n/label :t/contact-code)]
241-
[react/text {:style {:font-size 14}
242-
:selectable true
243-
:selection-color colors/hawkes-blue} public-key]]]))
242+
:accessibility-label :send-message-link}
243+
[vector-icons/icon :icons/chats {:style (styles/chat-profile-icon colors/blue)}]]
244+
[react/text {:style (styles/contact-card-text colors/blue)}
245+
(i18n/label :t/send-message)]]]
246+
[react/text {:style styles/chat-profile-contact-code} (i18n/label :t/contact-code)]
247+
[react/text {:style {:font-size 14}
248+
:selectable true
249+
:selection-color colors/hawkes-blue} whisper-identity]]])))

0 commit comments

Comments
 (0)