Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Components/Message/Message.css
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ pre code {
line-height: normal;
}

.message-text-rtl {
text-align: right;
}

.message-body {
overflow: hidden;
flex-grow: 1;
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Message/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
isEmptySelection
} from '../../Utils/Message';
import { getMedia } from '../../Utils/Media';
import { canSendMessages, isChannelChat, isGroupChat, isMeChat, isPrivateChat } from '../../Utils/Chat';
import { canSendMessages, isChannelChat, isGroupChat, isMeChat, isPrivateChat, isRTLChat } from '../../Utils/Chat';
import {
openUser,
openChat,
Expand Down Expand Up @@ -410,6 +410,7 @@ class Message extends Component {
const media = getMedia(message, this.openMedia, { hasTitle, hasCaption, inlineMeta, meta });
const isChannel = isChannelChat(chatId);
const isPrivate = isPrivateChat(chatId);
const messageIsRTL = isRTLChat(text);

// if (showTail && isMediaContent() && !hasCaption) {
// showTail = false;
Expand Down Expand Up @@ -525,7 +526,8 @@ class Message extends Component {
className={classNames('message-text', {
'message-text-1emoji': emojiMatches === 1,
'message-text-2emoji': emojiMatches === 2,
'message-text-3emoji': emojiMatches === 3
'message-text-3emoji': emojiMatches === 3,
'message-test-rtl': messageIsRTL
})}>
{text}
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/Utils/Chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,15 @@ function isPrivateChat(chatId) {
return false;
}

function isRTLChat(messageText){
if(!messageText) return false;
const pattern = new RegExp("[\u0600-\u06FF]");
if(pattern.test(messageText)) {
return true;
}
return false;
}

function isGroupChat(chatId) {
const chat = ChatStore.get(chatId);
if (!chat) return false;
Expand Down Expand Up @@ -2029,6 +2038,7 @@ export {
getChatUsername,
getChatPhoneNumber,
getChatBio,
isRTLChat,
isPrivateChat,
isGroupChat,
isChannelChat,
Expand Down