Skip to content

Commit c50ff89

Browse files
committed
Review Changes
1 parent fa0684c commit c50ff89

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/status_im/chat/models/mentions.cljs

+13-13
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@
205205
(fn [acc [key contact]]
206206
(let [mentionable-contact (add-searchable-phrases-to-contact contact false)]
207207
(if (nil? mentionable-contact) acc
208-
(assoc acc key mentionable-contact)))) {} contacts))
208+
(assoc acc key mentionable-contact))))
209+
{}
210+
contacts))
209211

210212
(defn mentionable-contacts-from-identites [contacts my-public-key identities]
211213
(reduce (fn [acc identity]
@@ -222,7 +224,7 @@
222224
{}
223225
(remove #(= my-public-key %) identities)))
224226

225-
(defn mentionable-users [chat all-contacts current-multiaccount community-members]
227+
(defn get-mentionable-users [chat all-contacts current-multiaccount community-members]
226228
(let [{:keys [name preferred-name public-key]} current-multiaccount
227229
{:keys [chat-id users contacts chat-type]} chat
228230
mentionable-contacts (mentionable-contacts all-contacts)
@@ -246,15 +248,6 @@
246248

247249
:else (merge mentionable-users mentionable-contacts))))
248250

249-
(defn get-mentionable-users
250-
[{:keys [db]}]
251-
(let [current-chat-id (:current-chat-id db)
252-
chat (get-in db [:chats current-chat-id])
253-
all-contacts (:contacts/contacts db)
254-
current-multiaccount (:multiaccount db)
255-
community-members (get-in db [:communities (:community-id chat) :members])]
256-
(mentionable-users chat all-contacts current-multiaccount community-members)))
257-
258251
(def ending-chars "[\\s\\.,;:]")
259252
(def ending-chars-regex (re-pattern ending-chars))
260253
(def word-regex (re-pattern (str "^[\\w\\d]*" ending-chars "|^[\\S]*$")))
@@ -365,8 +358,15 @@
365358
(recur new-text users (rest idxs)
366359
(+ diff (- (count text) (count new-text)))))))))))))
367360

368-
(defn check-mentions [cofx text]
369-
(replace-mentions text (get-mentionable-users cofx)))
361+
(defn check-mentions [{:keys [db]} text]
362+
(let [current-chat-id (:current-chat-id db)
363+
chat (get-in db [:chats current-chat-id])
364+
all-contacts (:contacts/contacts db)
365+
current-multiaccount (:multiaccount db)
366+
community-members (get-in db [:communities (:community-id chat) :members])]
367+
(replace-mentions
368+
text
369+
(get-mentionable-users chat all-contacts current-multiaccount community-members))))
370370

371371
(defn get-at-sign-idxs
372372
([text start]

src/status_im/subs.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@
14271427
(fn [[{:keys [users community-id] :as chat} blocked all-contacts
14281428
{:keys [public-key] :as current-multiaccount}]]
14291429
(let [community-members @(re-frame/subscribe [:communities/community-members community-id])
1430-
mentionable-users (mentions/mentionable-users chat all-contacts current-multiaccount community-members)
1430+
mentionable-users (mentions/get-mentionable-users chat all-contacts current-multiaccount community-members)
14311431
members-left (into #{} (filter #(group-chat/member-removed? chat %) (keys users)))]
14321432
(apply dissoc mentionable-users (conj (concat blocked members-left) public-key)))))
14331433

0 commit comments

Comments
 (0)