Skip to content

Commit

Permalink
Fix render error for text attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Aug 5, 2019
1 parent a46a8ff commit 558fb99
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import TextAttachment from '../../Attachment/TextAttachment';
import TypingActivity from '../../Attachment/TypingActivity';
import VideoAttachment from '../../Attachment/VideoAttachment';

function hasThumbnail(activity, attachment) {
const attachmentIndex = activity.attachments.indexOf(attachment);
const { channelData: { attachmentThumbnails = [] } = {} } = activity;
function hasThumbnail({ attachments = [], channelData: { attachmentThumbnails = [] } = {} }, attachment) {
const attachmentIndex = attachments.indexOf(attachment);

return !!attachmentThumbnails[attachmentIndex];
}
Expand All @@ -22,7 +21,7 @@ export default function createCoreMiddleware() {
const Attachment = ({ activity = {}, attachment, attachment: { contentType, contentUrl } = {} }) =>
activity.type === 'typing' ? (
<TypingActivity />
) : activity.from.role === 'user' && !hasThumbnail(activity, attachment) ? (
) : activity.from.role === 'user' && !/^text\//u.test(contentType) && !hasThumbnail(activity, attachment) ? (
<UploadAttachment activity={activity} attachment={attachment} />
) : /^audio\//u.test(contentType) ? (
<AudioAttachment activity={activity} attachment={attachment} />
Expand Down

0 comments on commit 558fb99

Please sign in to comment.