[#12919] Allow adding emoji to group intro message if it exceeds limit

This commit is contained in:
Roman Volosovskyi 2022-01-19 11:41:49 +02:00
parent eefc2ede81
commit bf92c51ce4
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 14 additions and 5 deletions

View File

@ -8,7 +8,8 @@
[status-im.i18n.i18n :as i18n]
[status-im.ui.components.list-selection :as list-selection]
[quo.design-system.colors :as colors]
[status-im.utils.debounce :as debounce])
[status-im.utils.debounce :as debounce]
[status-im.utils.platform :as platform])
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
(defn join-chat-button [chat-id]
@ -25,8 +26,11 @@
:on-press #(debounce/dispatch-and-chill [:group-chats.ui/leave-chat-confirmed chat-id] 2000)}
(i18n/label :t/group-chat-decline-invitation)])
(def message-max-length 100)
(defn request-membership [{:keys [state introduction-message] :as invitation}]
(let [{:keys [message retry?]} @(re-frame/subscribe [:chats/current-chat-membership])]
(let [{:keys [message retry?]} @(re-frame/subscribe [:chats/current-chat-membership])
message-length (count message)]
[react/view {:margin-horizontal 16 :margin-top 10}
(cond
(and invitation (= constants/invitation-state-requested state) (not retry?))
@ -52,7 +56,10 @@
[react/text (i18n/label :t/introduce-yourself)]
[quo/text-input {:placeholder (i18n/label :t/message)
:on-change-text #(re-frame/dispatch [:group-chats.ui/update-membership-message %])
:max-length 100
:max-length (if platform/android?
message-max-length
(when (>= message-length message-max-length)
message-length))
:multiline true
:default-value message
:accessibility-label :introduce-yourself-input

View File

@ -162,7 +162,8 @@
(defn invitation-bar [chat-id]
(let [{:keys [state chat-id] :as invitation}
(first @(re-frame/subscribe [:group-chat/invitations-by-chat-id chat-id]))
{:keys [retry? message]} @(re-frame/subscribe [:chats/current-chat-membership])]
{:keys [retry? message]} @(re-frame/subscribe [:chats/current-chat-membership])
message-length (count message)]
[react/view {:margin-horizontal 16 :margin-top 10}
(cond
(and invitation (= constants/invitation-state-requested state) (not retry?))
@ -193,7 +194,8 @@
[quo/button
{:type :secondary
:accessibility-label :introduce-yourself-button
:disabled (string/blank? message)
:disabled (or (string/blank? message)
(> message-length chat.group/message-max-length))
:on-press #(re-frame/dispatch [:send-group-chat-membership-request])}
(i18n/label :t/request-membership)]}])]))