Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1456e39

Browse files
committedMay 3, 2023
review
1 parent b29b479 commit 1456e39

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed
 

‎src/status_im2/contexts/chat/bottom_sheet_composer/mentions/view.cljs

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(ns status-im2.contexts.chat.bottom-sheet-composer.mentions.view
22
(:require
3+
[react-native.platform :as platform]
34
[reagent.core :as reagent]
45
[status-im2.contexts.chat.bottom-sheet-composer.utils :as utils]
56
[utils.re-frame :as rf]
@@ -9,12 +10,22 @@
910
[status-im2.contexts.chat.bottom-sheet-composer.mentions.style :as style]))
1011

1112
(defn mention-item
12-
[user]
13+
[user _ _ {:keys [cursor-position input-ref]}]
1314
[contact-list-item/contact-list-item
14-
{:on-press #(rf/dispatch [:chat.ui/select-mention nil user])} user])
15+
{:on-press (fn []
16+
(let [new-cursor-pos (+ (count (:primary-name user)) @cursor-position)]
17+
(rf/dispatch [:chat.ui/select-mention nil user])
18+
(when platform/android?
19+
(reset! cursor-position new-cursor-pos)
20+
(reagent/next-tick #(when @input-ref
21+
(.setNativeProps ^js @input-ref
22+
(clj->js {:selection {:start new-cursor-pos
23+
:end
24+
new-cursor-pos}})))))))}
25+
user])
1526

1627
(defn- f-view
17-
[suggestions suggestions-atom state animations max-height cursor-pos]
28+
[suggestions suggestions-atom props state animations max-height cursor-pos]
1829
(let [opacity (reanimated/use-shared-value (if (seq suggestions) 1 0))
1930
mentions-pos
2031
(utils/calc-suggestions-position cursor-pos state animations max-height (count suggestions))]
@@ -32,10 +43,12 @@
3243
:data (vals @suggestions-atom)
3344
:key-fn :key
3445
:render-fn mention-item
46+
:render-data {:cursor-position (:cursor-position state)
47+
:input-ref (:input-ref props)}
3548
:accessibility-label :mentions-list}]]))
3649

3750
(defn view
38-
[state animations max-height cursor-pos]
51+
[props state animations max-height cursor-pos]
3952
(let [suggestions (rf/sub [:chat/mention-suggestions])
4053
suggestions-atom (reagent/atom {})]
41-
[:f> f-view suggestions suggestions-atom state animations max-height cursor-pos]))
54+
[:f> f-view suggestions suggestions-atom props state animations max-height cursor-pos]))

‎src/status_im2/contexts/chat/bottom_sheet_composer/view.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
audio)
117117
(utils/update-input props state input-text)
118118
[:<>
119-
[mentions/view state animations max-height cursor-pos]
119+
[mentions/view props state animations max-height cursor-pos]
120120
[gesture/gesture-detector
121121
{:gesture (drag-gesture/drag-gesture props state animations dimensions keyboard-shown)}
122122
[reanimated/view

‎src/status_im2/subs/chat/chats.cljs

-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@
331331
(fn [[chat-id inputs]]
332332
(get-in inputs [chat-id :audio])))
333333

334-
335334
(re-frame/reg-sub
336335
:chats/timeline-sending-image
337336
:<- [:chats/timeline-chat-input]

0 commit comments

Comments
 (0)
Please sign in to comment.