diff --git a/src/status_im/chat/models/input.cljs b/src/status_im/chat/models/input.cljs index 795bb5e63a..3f1f8fc01f 100644 --- a/src/status_im/chat/models/input.cljs +++ b/src/status_im/chat/models/input.cljs @@ -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 - #":([a-z_\-+0-9]*):" - (fn [[original emoji-id]] - (if-let [emoji-map (object/get (.-lib emojis) emoji-id)] - (.-char ^js emoji-map) - original))))) + (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)))) (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 diff --git a/src/status_im/chat/models/mentions.cljs b/src/status_im/chat/models/mentions.cljs index 2312d04484..91362e11a9 100644 --- a/src/status_im/chat/models/mentions.cljs +++ b/src/status_im/chat/models/mentions.cljs @@ -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 diff --git a/src/status_im/subs.cljs b/src/status_im/subs.cljs index 2278b67dfb..f852dc8b3c 100644 --- a/src/status_im/subs.cljs +++ b/src/status_im/subs.cljs @@ -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 diff --git a/src/status_im/ui/screens/profile/contact/views.cljs b/src/status_im/ui/screens/profile/contact/views.cljs index 2c508a93bf..570cf1834c 100644 --- a/src/status_im/ui/screens/profile/contact/views.cljs +++ b/src/status_im/ui/screens/profile/contact/views.cljs @@ -80,20 +80,21 @@ (defn render-chat-settings [{:keys [public-key names]}] (let [muted? (:muted @(re-frame/subscribe [:chats/chat public-key]))] - [quo/list-item - {:title (i18n/label :t/nickname) - :size :small - :accessibility-label :profile-nickname-item - :accessory :text - :accessory-text (or (:nickname names) (i18n/label :t/none)) - :on-press #(re-frame/dispatch [:navigate-to :nickname]) - :chevron true}] - [quo/list-item - {:title (i18n/label :mute-chat) - :active muted? - :accessibility-label :mute-chat - :on-press #(re-frame/dispatch [::chat.models/mute-chat-toggled public-key (not muted?)]) - :accessory :switch}])) + [react/view + [quo/list-item + {:title (i18n/label :t/nickname) + :size :small + :accessibility-label :profile-nickname-item + :accessory :text + :accessory-text (or (:nickname names) (i18n/label :t/none)) + :on-press #(re-frame/dispatch [:navigate-to :nickname]) + :chevron true}] + [quo/list-item + {: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}]])) (defn chat-settings [contact] [react/view diff --git a/src/status_im/utils/utils.cljs b/src/status_im/utils/utils.cljs index 7212ae2111..70955496fa 100644 --- a/src/status_im/utils/utils.cljs +++ b/src/status_im/utils/utils.cljs @@ -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))) \ No newline at end of file diff --git a/translations/en.json b/translations/en.json index c8d228e9d4..27b5532223 100644 --- a/translations/en.json +++ b/translations/en.json @@ -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" }