Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e8ce65167 | ||
|
|
8090f37bdd | ||
|
|
54825c6735 | ||
|
|
030f17fc49 | ||
|
|
2bc7d15683 |
@@ -4,7 +4,6 @@
|
||||
[quo.react-native :as rn]
|
||||
[re-frame.core :as re-frame]
|
||||
[utils.re-frame :as rf]
|
||||
[status-im.utils.platform :as platform]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.native-module.core :as status]))
|
||||
|
||||
@@ -91,38 +90,29 @@
|
||||
(assoc-in [:chats/mentions chat-id :mentions] state)
|
||||
(assoc-in [:chat/inputs-with-mentions chat-id] input-segments))}))
|
||||
|
||||
(rf/defn on-text-input
|
||||
{:events [:mention/on-text-input]}
|
||||
[{:keys [db]} {:keys [previous-text start end] :as args}]
|
||||
(let [previous-text
|
||||
;; NOTE(rasom): on iOS `previous-text` contains entire input's text. To
|
||||
;; get only removed part of text we have cut it.
|
||||
(if platform/android?
|
||||
previous-text
|
||||
(subs previous-text start end))
|
||||
chat-id (:current-chat-id db)
|
||||
state (merge args {:previous-text previous-text})
|
||||
state (set/rename-keys state
|
||||
{:previous-text :PreviousText
|
||||
:new-text :NewText
|
||||
:start :Start
|
||||
:end :End})
|
||||
params [chat-id state]
|
||||
method "wakuext_chatMentionOnTextInput"]
|
||||
(log/debug "[mentions] on-text-input" {:params params})
|
||||
(rf/defn on-change-text
|
||||
{:events [:mention/on-change-text]}
|
||||
[{:keys [db]} text]
|
||||
(let [chat-id (:current-chat-id db)
|
||||
params [chat-id text]
|
||||
method "wakuext_chatMentionOnChangeText"]
|
||||
(log/debug "[mentions] on-change-text" {:params params})
|
||||
{:json-rpc/call [{:method method
|
||||
:params [chat-id state]
|
||||
:on-success #(rf/dispatch [:mention/on-text-input-success %])
|
||||
:params params
|
||||
:on-success #(rf/dispatch [:mention/on-change-text-success %])
|
||||
:on-error #(rf/dispatch [:mention/on-error
|
||||
{:method method
|
||||
:params params} %])}]}))
|
||||
|
||||
(rf/defn on-text-input-success
|
||||
{:events [:mention/on-text-input-success]}
|
||||
(rf/defn on-change-text-success
|
||||
{:events [:mention/on-change-text-success]}
|
||||
[{:keys [db]} result]
|
||||
(log/debug "[mentions] on-text-input-success" {:result result})
|
||||
(let [{:keys [state chat-id]} (transfer-mention-result result)]
|
||||
{:db (assoc-in db [:chats/mentions chat-id :mentions] state)}))
|
||||
(let [{:keys [state chat-id mentionable-users input-segments]} (transfer-mention-result result)]
|
||||
{:db (-> db
|
||||
(assoc-in [:chats/mention-suggestions chat-id] mentionable-users)
|
||||
(assoc-in [:chats/mentions chat-id :mentions] state)
|
||||
(assoc-in [:chat/inputs-with-mentions chat-id] input-segments))}))
|
||||
|
||||
(rf/defn recheck-at-idxs
|
||||
[{:keys [db]} public-key]
|
||||
@@ -175,16 +165,6 @@
|
||||
;; programmatic change. By calling `reset-text-input-cursor` we force the
|
||||
;; keyboard's cursor position to be changed before the next input.
|
||||
(reset-text-input-cursor text-input-ref cursor)
|
||||
;; NOTE(roman): on-text-input event is not dispatched when we change input
|
||||
;; programmatically, so we have to call `on-text-input` manually
|
||||
(on-text-input
|
||||
(let [match-len (count match)
|
||||
start (inc at-sign-idx)
|
||||
end (+ start match-len)]
|
||||
{:new-text match
|
||||
:previous-text searched-text
|
||||
:start start
|
||||
:end end}))
|
||||
(recheck-at-idxs public-key))))
|
||||
|
||||
(rf/defn clear-suggestions
|
||||
@@ -220,7 +200,7 @@
|
||||
(when text
|
||||
(log/debug "[mentions] check-selection" {:params params})
|
||||
{:json-rpc/call [{:method method
|
||||
:params [chat-id text start end]
|
||||
:params params
|
||||
:on-success #(rf/dispatch [:mention/on-handle-selection-change-success %])
|
||||
:on-error #(rf/dispatch [:mention/on-error
|
||||
{:method method
|
||||
@@ -230,8 +210,11 @@
|
||||
{:events [:mention/on-handle-selection-change-success]}
|
||||
[{:keys [db]} result]
|
||||
(log/debug "[mentions] on-check-selection-success" {:result result})
|
||||
(let [{:keys [state chat-id]} (transfer-mention-result result)]
|
||||
{:db (assoc-in db [:chats/mentions chat-id :mentions] (rename-state state))}))
|
||||
(let [{:keys [state chat-id mentionable-users input-segments]} (transfer-mention-result result)]
|
||||
{:db (-> db
|
||||
(assoc-in [:chats/mention-suggestions chat-id] mentionable-users)
|
||||
(assoc-in [:chats/mentions chat-id :mentions] state)
|
||||
(assoc-in [:chat/inputs-with-mentions chat-id] input-segments))}))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::reset-text-input-cursor
|
||||
@@ -240,28 +223,3 @@
|
||||
(status/reset-keyboard-input
|
||||
(rn/find-node-handle (react/current-ref ref))
|
||||
cursor))))
|
||||
|
||||
(rf/defn calculate-suggestions
|
||||
{:events [:mention/calculate-suggestions]}
|
||||
[{:keys [db]}]
|
||||
(let [chat-id (:current-chat-id db)
|
||||
text (get-in db [:chat/inputs chat-id :input-text])
|
||||
params [chat-id text]
|
||||
method "wakuext_chatMentionCalculateSuggestions"]
|
||||
(log/debug "[mentions] calculate-suggestions" {:params params})
|
||||
{:json-rpc/call [{:method method
|
||||
:params [chat-id text]
|
||||
:on-success #(rf/dispatch [:mention/on-calculate-suggestions-success %])
|
||||
:on-error #(rf/dispatch [:mention/on-error
|
||||
{:method method
|
||||
:params params} %])}]}))
|
||||
|
||||
(rf/defn on-calculate-suggestions-success
|
||||
{:events [:mention/on-calculate-suggestions-success]}
|
||||
[{:keys [db]} result]
|
||||
(log/debug "[mentions] on-calculate-suggestions-success" {:result result})
|
||||
(let [{:keys [state chat-id mentionable-users input-segments]} (transfer-mention-result result)]
|
||||
{:db (-> db
|
||||
(assoc-in [:chats/mention-suggestions chat-id] mentionable-users)
|
||||
(assoc-in [:chats/mentions chat-id :mentions] state)
|
||||
(assoc-in [:chat/inputs-with-mentions chat-id] input-segments))}))
|
||||
|
||||
@@ -198,11 +198,7 @@
|
||||
(when platform/android?
|
||||
(reset! last-text-change (js/Date.now)))
|
||||
|
||||
(on-text-change text chat-id)
|
||||
;; NOTE(rasom): on iOS `on-change` is dispatched after `on-text-input`,
|
||||
;; that's why mention suggestions are calculated on `on-change`
|
||||
(when platform/ios?
|
||||
(re-frame/dispatch [:mention/calculate-suggestions]))))
|
||||
(on-text-change text chat-id)))
|
||||
|
||||
(rf/defn set-input-text
|
||||
"Set input text for current-chat. Takes db and input text and cofx
|
||||
@@ -220,26 +216,10 @@
|
||||
|
||||
(defn on-text-input
|
||||
[chat-id args]
|
||||
(let [native-event (.-nativeEvent ^js args)
|
||||
text (.-text ^js native-event)
|
||||
previous-text (.-previousText ^js native-event)
|
||||
range (.-range ^js native-event)
|
||||
start (.-start ^js range)
|
||||
end (.-end ^js range)]
|
||||
(let [native-event (.-nativeEvent ^js args)
|
||||
text (.-text ^js native-event)]
|
||||
(when (and (not (get @mentions-enabled chat-id)) (string/index-of text "@"))
|
||||
(swap! mentions-enabled assoc chat-id true))
|
||||
|
||||
(re-frame/dispatch
|
||||
[:mention/on-text-input
|
||||
{:new-text text
|
||||
:previous-text previous-text
|
||||
:start start
|
||||
:end end}])
|
||||
;; NOTE(rasom): on Android `on-text-input` is dispatched after
|
||||
;; `on-change`, that's why mention suggestions are calculated
|
||||
;; on `on-change`
|
||||
(when platform/android?
|
||||
(re-frame/dispatch [:mention/calculate-suggestions]))))
|
||||
(swap! mentions-enabled assoc chat-id true))))
|
||||
|
||||
(defn text-input
|
||||
[{:keys [set-active-panel refs chat-id sending-image]}]
|
||||
|
||||
@@ -141,33 +141,15 @@
|
||||
(reset! last-text-change (js/Date.now)))
|
||||
|
||||
(on-text-change text chat-id)
|
||||
;; NOTE(rasom): on iOS `on-change` is dispatched after `on-text-input`,
|
||||
;; that's why mention suggestions are calculated on `on-change`
|
||||
(when platform/ios?
|
||||
(rf/dispatch [:mention/calculate-suggestions]))))
|
||||
|
||||
(rf/dispatch [:mention/on-change-text text])))
|
||||
|
||||
(defn on-text-input
|
||||
[chat-id args]
|
||||
(let [native-event (.-nativeEvent ^js args)
|
||||
text (.-text ^js native-event)
|
||||
previous-text (.-previousText ^js native-event)
|
||||
range (.-range ^js native-event)
|
||||
start (.-start ^js range)
|
||||
end (.-end ^js range)]
|
||||
(let [native-event (.-nativeEvent ^js args)
|
||||
text (.-text ^js native-event)]
|
||||
(when (and (not (get @mentions-enabled? chat-id)) (string/index-of text "@"))
|
||||
(swap! mentions-enabled? assoc chat-id true))
|
||||
|
||||
(rf/dispatch
|
||||
[:mention/on-text-input
|
||||
{:new-text text
|
||||
:previous-text previous-text
|
||||
:start start
|
||||
:end end}])
|
||||
;; NOTE(rasom): on Android `on-text-input` is dispatched after
|
||||
;; `on-change`, that's why mention suggestions are calculated
|
||||
;; on `on-change`
|
||||
(when platform/android?
|
||||
(rf/dispatch [:mention/calculate-suggestions]))))
|
||||
(swap! mentions-enabled? assoc chat-id true))))
|
||||
|
||||
(defn text-input-style
|
||||
[chat-id]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.145.2",
|
||||
"commit-sha1": "719af90fcc077f301f50349c034938701883031e",
|
||||
"src-sha256": "1p93x7ph03aq95961j4098fy2p7a4ssymf4hf3kbl5ldmvdk403p"
|
||||
"version": "fix/15616",
|
||||
"commit-sha1": "2eccfda1c9495a3a6ecfd96f24efefff1b53461f",
|
||||
"src-sha256": "0dhibgmfix23nmmg5nhyhg6qr069575mi1hp4gqd4rp54wygigvv"
|
||||
}
|
||||
|
||||
@@ -332,7 +332,6 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase):
|
||||
self.errors.verify_no_errors()
|
||||
|
||||
@marks.testrail_id(702957)
|
||||
@marks.xfail(reason="Blocked by 15500")
|
||||
def test_activity_center_mentions(self):
|
||||
self.home_1.jump_to_communities_home()
|
||||
self.home_2.jump_to_card_by_text('# %s' % self.channel_name)
|
||||
|
||||
@@ -811,7 +811,7 @@ class ChatView(BaseView):
|
||||
self.set_community_image_button = Button(self.driver, translation_id='community-thumbnail-image',
|
||||
suffix='/following-sibling::android.view.ViewGroup')
|
||||
self.confirm_create_in_community_button = Button(self.driver, translation_id="create")
|
||||
self.mentions_list = BaseElement(self.driver, accessibility_id="mentions-list")
|
||||
self.mentions_list = BaseElement(self.driver, accessibility_id="user-list")
|
||||
|
||||
# New UI
|
||||
self.pinned_messages_count = Button(self.driver,
|
||||
|
||||
Reference in New Issue
Block a user