|
10 | 10 | [taoensso.timbre :as log]
|
11 | 11 | [status-im.chat.models.mentions :as mentions]
|
12 | 12 | [clojure.string :as string]
|
13 |
| - [status-im.contact.db :as contact.db] |
14 | 13 | [status-im.utils.types :as types]
|
15 | 14 | [status-im.ui.screens.chat.state :as view.state]
|
16 | 15 | [status-im.chat.models.loading :as chat.loading]
|
17 |
| - [status-im.utils.platform :as platform])) |
| 16 | + [status-im.utils.platform :as platform] |
| 17 | + [status-im.utils.gfycat.core :as gfycat])) |
18 | 18 |
|
19 | 19 | (defn- message-loaded?
|
20 | 20 | [db chat-id message-id]
|
|
39 | 39 | {:events [:chat/add-senders-to-chat-users]}
|
40 | 40 | [{:keys [db]} messages]
|
41 | 41 | (reduce (fn [acc {:keys [chat-id alias name identicon from]}]
|
42 |
| - (update-in acc [:db :chats chat-id :users] assoc |
43 |
| - from |
44 |
| - (mentions/add-searchable-phrases |
45 |
| - {:alias alias |
46 |
| - :name (or name alias) |
47 |
| - :identicon identicon |
48 |
| - :public-key from |
49 |
| - :nickname (get-in db [:contacts/contacts from :nickname])}))) |
| 42 | + (let [alias (if (string/blank? alias) |
| 43 | + (gfycat/generate-gfy from) |
| 44 | + alias)] |
| 45 | + (update-in acc [:db :chats chat-id :users] assoc |
| 46 | + from |
| 47 | + (mentions/add-searchable-phrases |
| 48 | + {:alias alias |
| 49 | + :name (or name alias) |
| 50 | + :identicon identicon |
| 51 | + :public-key from |
| 52 | + :nickname (get-in db [:contacts/contacts from :nickname])})))) |
50 | 53 | {:db db}
|
51 | 54 | messages))
|
52 | 55 |
|
|
56 | 59 | (or
|
57 | 60 | (= chat-id (chat-model/my-profile-chat-topic db))
|
58 | 61 | (when-let [pub-key (get-in db [:chats chat-id :profile-public-key])]
|
59 |
| - (contact.db/added? db pub-key))))) |
| 62 | + (get-in db [:contacts/contacts pub-key :added]))))) |
60 | 63 |
|
61 | 64 | (defn get-timeline-message [db chat-id message-js]
|
62 | 65 | (when (timeline-message? db chat-id)
|
63 | 66 | (data-store.messages/<-rpc (types/js->clj message-js))))
|
64 | 67 |
|
65 | 68 | (defn add-message [{:keys [db] :as acc} message-js chat-id message-id cursor-clock-value]
|
66 |
| - (let [{:keys [alias replace from clock-value] :as message} |
| 69 | + (let [{:keys [replace from clock-value] :as message} |
67 | 70 | (data-store.messages/<-rpc (types/js->clj message-js))]
|
68 | 71 | (if (message-loaded? db chat-id message-id)
|
69 | 72 | ;; If the message is already loaded, it means it's an update, that
|
|
83 | 86 | :cursor-clock-value clock-value)
|
84 | 87 |
|
85 | 88 | ;;conj sender for add-sender-to-chat-users
|
86 |
| - (and (not (string/blank? alias)) |
87 |
| - (not (get-in db [:chats chat-id :users from]))) |
| 89 | + (not (get-in db [:chats chat-id :users from])) |
88 | 90 | (update :senders assoc from message)
|
89 | 91 |
|
90 | 92 | (not (string/blank? replace))
|
|
0 commit comments