Skip to content

Commit 8c9c93a

Browse files
committed
fix: moved edit-mentions logic to use-edit to fix unresolved mention
1 parent 7ad8165 commit 8c9c93a

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

src/status_im2/contexts/chat/composer/effects.cljs

+8-20
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,15 @@
106106
(defn use-edit
107107
[{:keys [input-ref]}
108108
{:keys [text-value saved-cursor-position]}
109-
{:keys [edit]}]
109+
{:keys [edit input-with-mentions]}]
110110
(rn/use-effect
111111
(fn []
112-
(let [edit-text (get-in edit [:content :text])
112+
(let [mention? (some #(= :mention (first %)) (seq input-with-mentions))
113+
mention-text (reduce (fn [acc item]
114+
(str acc (second item)))
115+
""
116+
input-with-mentions)
117+
edit-text (if mention? mention-text (get-in edit [:content :text]))
113118
text-value-count (count @text-value)
114119
inject-edit-text (fn []
115120
(reset! text-value edit-text)
@@ -128,7 +133,7 @@
128133
;; text.
129134
(js/setTimeout #(do (.focus ^js @input-ref)
130135
(js/setTimeout inject-edit-text 250))
131-
250))))
136+
100))))
132137
[(:message-id edit)]))
133138

134139
(defn use-reply
@@ -143,23 +148,6 @@
143148
(js/setTimeout #(.focus ^js @input-ref) 250)))
144149
[(:message-id reply)]))
145150

146-
(defn edit-mentions
147-
[{:keys [input-ref]} {:keys [text-value cursor-position]} {:keys [input-with-mentions]}]
148-
(rn/use-effect (fn []
149-
(let [input-text (reduce (fn [acc item]
150-
(str acc (second item)))
151-
""
152-
input-with-mentions)]
153-
(reset! text-value input-text)
154-
(reset! cursor-position (count input-text))
155-
(js/setTimeout #(when @input-ref
156-
(.setNativeProps ^js @input-ref
157-
(clj->js {:selection {:start (count input-text)
158-
:end (count
159-
input-text)}})))
160-
300)))
161-
[(some #(= :mention (first %)) (seq input-with-mentions))]))
162-
163151
(defn update-input-mention
164152
[{:keys [input-ref]}
165153
{:keys [text-value]}

src/status_im2/contexts/chat/composer/view.cljs

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
(effects/use-edit props state subscriptions)
7777
(effects/use-reply props animations subscriptions)
7878
(effects/update-input-mention props state subscriptions)
79-
(effects/edit-mentions props state subscriptions)
8079
(effects/link-previews props state animations subscriptions)
8180
(effects/use-images props state animations subscriptions)
8281
[:<>

0 commit comments

Comments
 (0)