Skip to content

Commit

Permalink
Add error message when chat/intro is too long
Browse files Browse the repository at this point in the history
  • Loading branch information
duogenesis committed Dec 17, 2023
1 parent 14fd911 commit 6b16ba7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/conversation-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ const ConversationScreen = ({navigation, route}) => {
{lastMessageStatus === 'timeout' ? "Message not delivered. Are you online?" : '' }
{lastMessageStatus === 'blocked' ? name + ' is unavailable right now. Try messaging someone else!' : '' }
{lastMessageStatus === 'not unique' ? `Someone already sent that intro! Try sending ${name} a different message...` : '' }
{lastMessageStatus === 'too long' ? 'That message is too big! 😩' : '' }
</DefaultText>
{!messageFetchTimeout && isAvailableUser &&
<TextInputWithButton onPress={onPressSend}/>
Expand Down
8 changes: 8 additions & 0 deletions xmpp/xmpp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type MessageStatus =
| 'sent'
| 'blocked'
| 'not unique'
| 'too long'
| 'timeout'

type Message = {
Expand Down Expand Up @@ -433,6 +434,11 @@ const _sendMessage = (

if (!doc) return;

const tooLongNode = xpath.select1(
`/*[name()='duo_message_too_long'][@id='${id}']`,
doc
);

const notUniqueNode = xpath.select1(
`/*[name()='duo_message_not_unique'][@id='${id}']`,
doc
Expand All @@ -452,6 +458,8 @@ const _sendMessage = (
callback('blocked');
} else if (notUniqueNode) {
callback('not unique');
} else if (tooLongNode) {
callback('too long');
} else if (messageDeliveredNode) {
setInboxSent(recipientPersonId, message);
callback('sent');
Expand Down

0 comments on commit 6b16ba7

Please sign in to comment.