Skip to content

Commit

Permalink
Review Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Parveshdhull committed Jan 12, 2022
1 parent fa0684c commit c50ff89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions src/status_im/chat/models/mentions.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@
(fn [acc [key contact]]
(let [mentionable-contact (add-searchable-phrases-to-contact contact false)]
(if (nil? mentionable-contact) acc
(assoc acc key mentionable-contact)))) {} contacts))
(assoc acc key mentionable-contact))))
{}
contacts))

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

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

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

(defn get-mentionable-users
[{:keys [db]}]
(let [current-chat-id (:current-chat-id db)
chat (get-in db [:chats current-chat-id])
all-contacts (:contacts/contacts db)
current-multiaccount (:multiaccount db)
community-members (get-in db [:communities (:community-id chat) :members])]
(mentionable-users chat all-contacts current-multiaccount community-members)))

(def ending-chars "[\\s\\.,;:]")
(def ending-chars-regex (re-pattern ending-chars))
(def word-regex (re-pattern (str "^[\\w\\d]*" ending-chars "|^[\\S]*$")))
Expand Down Expand Up @@ -365,8 +358,15 @@
(recur new-text users (rest idxs)
(+ diff (- (count text) (count new-text)))))))))))))

(defn check-mentions [cofx text]
(replace-mentions text (get-mentionable-users cofx)))
(defn check-mentions [{:keys [db]} text]
(let [current-chat-id (:current-chat-id db)
chat (get-in db [:chats current-chat-id])
all-contacts (:contacts/contacts db)
current-multiaccount (:multiaccount db)
community-members (get-in db [:communities (:community-id chat) :members])]
(replace-mentions
text
(get-mentionable-users chat all-contacts current-multiaccount community-members))))

(defn get-at-sign-idxs
([text start]
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/subs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@
(fn [[{:keys [users community-id] :as chat} blocked all-contacts
{:keys [public-key] :as current-multiaccount}]]
(let [community-members @(re-frame/subscribe [:communities/community-members community-id])
mentionable-users (mentions/mentionable-users chat all-contacts current-multiaccount community-members)
mentionable-users (mentions/get-mentionable-users chat all-contacts current-multiaccount community-members)
members-left (into #{} (filter #(group-chat/member-removed? chat %) (keys users)))]
(apply dissoc mentionable-users (conj (concat blocked members-left) public-key)))))

Expand Down

0 comments on commit c50ff89

Please sign in to comment.