Skip to content

Commit

Permalink
fix: [SendConfirm] remove S--modalOpen after close SendConfirm
Browse files Browse the repository at this point in the history
  • Loading branch information
akai committed May 24, 2021
1 parent 1e6ad64 commit f0b95da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions demo/src/demo/Chat.tsx
Expand Up @@ -286,6 +286,7 @@ export default () => {
quickReplies={quickReplies}
onQuickReplyClick={handleQuickReplyClick}
onSend={handleSend}
onImageSend={() => Promise.resolve()}
/>
</div>
</DemoSection>
Expand Down
10 changes: 5 additions & 5 deletions src/components/SendConfirm/SendConfirm.tsx
Expand Up @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
import { Modal } from '../Modal';
import { Flex } from '../Flex';
import { useLocale } from '../LocaleProvider';
import toggleClass from '../../utils/toggleClass';

export type SendConfirmProps = {
file: Blob;
Expand All @@ -15,18 +16,17 @@ export const SendConfirm: React.FC<SendConfirmProps> = (props) => {
const { trans } = useLocale('SendConfirm');

useEffect(() => {
if (!file) {
setImg('');
return;
}

const reader = new FileReader();
reader.onload = (e: ProgressEvent<FileReader>) => {
if (e.target) {
setImg(e.target.result as string);
}
};
reader.readAsDataURL(file);

return () => {
toggleClass('S--modalOpen', false);
};
}, [file]);

return (
Expand Down

0 comments on commit f0b95da

Please sign in to comment.