fix mentions delay (#16025)

* fix mentions delay
This commit is contained in:
Omar Basem 2023-05-25 13:56:22 +04:00 committed by GitHub
parent b7cc54a356
commit 7ec5117f54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View File

@ -9,7 +9,6 @@
[status-im2.contexts.chat.composer.constants :as constants]
[status-im2.contexts.chat.composer.keyboard :as kb]
[status-im2.contexts.chat.composer.utils :as utils]
[utils.debounce :as debounce]
[utils.number :as utils.number]
[utils.re-frame :as rf]))
@ -183,7 +182,7 @@
(when @input-ref
(.setNativeProps ^js @input-ref (clj->js {:text input-text})))
(reset! text-value input-text)
(debounce/debounce-and-dispatch [:mention/on-change-text input-text] 300)))
(rf/dispatch [:mention/on-change-text input-text])))
[input-text]))
(defn did-mount

View File

@ -1,5 +1,6 @@
(ns status-im2.contexts.chat.composer.handlers
(:require
[clojure.string :as string]
[oops.core :as oops]
[react-native.core :as rn]
[react-native.reanimated :as reanimated]
@ -60,7 +61,7 @@
(defn content-size-change
[event
{:keys [maximized? lock-layout?]}
{:keys [maximized? lock-layout? text-value]}
{:keys [height saved-height opacity background-y]}
{:keys [content-height window-height max-height]}
keyboard-shown]
@ -68,7 +69,7 @@
(let [event-size (oops/oget event "nativeEvent.contentSize.height")
content-size (+ event-size constants/extra-content-offset)
lines (utils/calc-lines event-size)
content-size (if (= lines 1)
content-size (if (or (= lines 1) (empty? @text-value))
constants/input-height
(if (= lines 2) constants/multiline-minimized-height content-size))
new-height (utils/bounded-val content-size constants/input-height max-height)]
@ -120,7 +121,9 @@
(@record-reset-fn)
(reset! recording? false))
(rf/dispatch [:chat.ui/set-chat-input-text text])
(debounce/debounce-and-dispatch [:mention/on-change-text text] 300))
(if (string/ends-with? text "@")
(rf/dispatch [:mention/on-change-text text])
(debounce/debounce-and-dispatch [:mention/on-change-text text] 300)))
(defn selection-change
[event

View File

@ -143,7 +143,6 @@
base
(+ constants/actions-container-height (:bottom insets) (- curr-height cursor-pos) 18)))))
(defn init-props
[]
{:input-ref (atom nil)