Skip to content

Commit

Permalink
Merge pull request #638 from mdshamoon/feature/last-message-icons
Browse files Browse the repository at this point in the history
Added icons for media on contact's last message
  • Loading branch information
rathorevaibhav authored Oct 26, 2020
2 parents 9027d27 + 2c3ab85 commit fcb676f
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 18 deletions.
14 changes: 14 additions & 0 deletions src/assets/images/icons/Audio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/assets/images/icons/Image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/assets/images/icons/Video.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

.MessageContent {
font-size: 15px;
display: flex;
margin-top: 2px;
text-overflow: ellipsis;
overflow: hidden;
Expand All @@ -67,6 +68,10 @@
margin: 0px;
}

.MessageContent svg{
margin-right: 8px;
}

.MessageDate {
position: absolute;
color: gray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { MARK_AS_READ, MESSAGE_FRAGMENT } from '../../../../graphql/mutations/Ch
import { useApolloClient, useMutation } from '@apollo/client';
import { WhatsAppToJsx } from '../../../../common/RichEditor';
import { Timer } from '../../../../components/UI/Timer/Timer';
import { ReactComponent as ImageIcon } from '../../../../assets/images/icons/Image.svg';
import { ReactComponent as VideoIcon } from '../../../../assets/images/icons/Video.svg';
import { ReactComponent as AudioIcon } from '../../../../assets/images/icons/Audio.svg';
import { SEARCH_OFFSET } from '../../../../graphql/queries/Search';

export interface ChatConversationProps {
Expand Down Expand Up @@ -82,20 +85,26 @@ const ChatConversation: React.SFC<ChatConversationProps> = (props) => {
const BoldedText = (text: string, highlight: any) => {
highlight = highlight ? highlight : '';
// Split on highlight term and include term into strings, ignore case
const strings = text.split(new RegExp(`(${highlight})`, 'gi'));
return (
<span>
{strings.map((string, i) =>
string.toLowerCase() === highlight.toLowerCase() ? (
<span key={i} className={styles.TitleText}>
{string}
</span>
) : (
string
)
)}
</span>
);
const strings =
typeof text === 'string' ? text.split(new RegExp(`(${highlight})`, 'gi')) : null;

if (strings) {
return (
<span>
{strings.map((string, i) =>
string.toLowerCase() === highlight.toLowerCase() ? (
<span key={i} className={styles.TitleText}>
{string}
</span>
) : (
string
)
)}
</span>
);
} else {
return text;
}
};

useEffect(() => {
Expand All @@ -112,10 +121,36 @@ const ChatConversation: React.SFC<ChatConversationProps> = (props) => {

// checking if the last message type is text and displaying the message below the contact name
// else displaying the type of message
if (lastMessage.type === 'TEXT') {
message = lastMessage.body;
} else {
message = lastMessage.type;
switch (lastMessage.type) {
case 'TEXT':
message = lastMessage.body;
break;
case 'IMAGE':
message = (
<>
<ImageIcon />
Image
</>
);
break;
case 'VIDEO':
message = (
<>
<VideoIcon />
Video
</>
);
break;
case 'AUDIO':
message = (
<>
<AudioIcon />
Audio
</>
);
break;
default:
message = lastMessage.type;
}
let displayMSG = WhatsAppToJsx(message);

Expand Down

0 comments on commit fcb676f

Please sign in to comment.