fix local names , mute chat translation, replace null crash

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2020-09-14 08:44:34 +02:00
parent 32cb09c9c6
commit 59e226bab2
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
6 changed files with 35 additions and 27 deletions

View File

@ -10,18 +10,18 @@
[status-im.utils.datetime :as datetime]
[status-im.utils.fx :as fx]
["emojilib" :as emojis]
[status-im.chat.models.mentions :as mentions]))
[status-im.chat.models.mentions :as mentions]
[status-im.utils.utils :as utils]))
(defn text->emoji
"Replaces emojis in a specified `text`"
[text]
(when text
(string/replace text
(utils/safe-replace text
#":([a-z_\-+0-9]*):"
(fn [[original emoji-id]]
(if-let [emoji-map (object/get (.-lib emojis) emoji-id)]
(.-char ^js emoji-map)
original)))))
original))))
(fx/defn set-chat-input-text
"Set input text for current-chat. Takes db and input text and cofx
@ -119,7 +119,7 @@
(when-not (string/blank? image-path)
(chat.message/send-message {:chat-id current-chat-id
:content-type constants/content-type-image
:image-path (string/replace image-path #"file://" "")
:image-path (utils/safe-replace image-path #"file://" "")
:text (i18n/label :t/update-to-see-image)})))))
(fx/defn send-audio-message

View File

@ -3,7 +3,8 @@
[status-im.utils.fx :as fx]
[status-im.contact.db :as contact.db]
[status-im.utils.platform :as platform]
[taoensso.timbre :as log]))
[taoensso.timbre :as log]
[status-im.utils.utils :as utils]))
(def at-sign "@")
@ -36,7 +37,7 @@
:else users)]
(reduce
(fn [acc [key {:keys [alias name identicon]}]]
(let [name (string/replace name ".stateofus.eth" "")]
(let [name (utils/safe-replace name ".stateofus.eth" "")]
(assoc acc alias {:alias alias
:name (or name alias)
:identicon identicon

View File

@ -38,6 +38,7 @@
[status-im.utils.security :as security]
[status-im.wallet.db :as wallet.db]
[status-im.wallet.utils :as wallet.utils]
[status-im.utils.utils :as utils]
status-im.ui.screens.keycard.subs
status-im.ui.screens.keycard.settings.subs
status-im.ui.screens.keycard.pin.subs
@ -863,7 +864,7 @@
(reduce
(fn [acc [key {:keys [alias name identicon]}]]
(if (and alias (not= alias ""))
(let [name (string/replace name ".stateofus.eth" "")]
(let [name (utils/safe-replace name ".stateofus.eth" "")]
(assoc acc alias {:alias alias
:name (or name alias)
:identicon identicon

View File

@ -80,6 +80,7 @@
(defn render-chat-settings [{:keys [public-key names]}]
(let [muted? (:muted @(re-frame/subscribe [:chats/chat public-key]))]
[react/view
[quo/list-item
{:title (i18n/label :t/nickname)
:size :small
@ -89,11 +90,11 @@
:on-press #(re-frame/dispatch [:navigate-to :nickname])
:chevron true}]
[quo/list-item
{:title (i18n/label :mute-chat)
{:title (i18n/label :t/mute)
:active muted?
:accessibility-label :mute-chat
:on-press #(re-frame/dispatch [::chat.models/mute-chat-toggled public-key (not muted?)])
:accessory :switch}]))
:accessory :switch}]]))
(defn chat-settings [contact]
[react/view

View File

@ -118,3 +118,7 @@
(defn safe-trim [s]
(when (string? s)
(string/trim s)))
(defn safe-replace [s m r]
(when (string? s)
(string/replace s m r)))

View File

@ -1258,5 +1258,6 @@
"request-membership": "Request membership",
"membership-description": "Group membership requires you to be accepted by the group admin",
"group-membership-request": "Group membership request",
"members-limit-reached": "Members limit reached"
"members-limit-reached": "Members limit reached",
"mute": "Mute"
}