Browse Source

fix: create text message

stage
Vitalik 3 weeks ago
parent
commit
c7248f8259
  1. 48
      src/containers/Chats/components/show-doc-modal.component.tsx
  2. 19
      src/containers/Chats/hooks/use-create-text-message.hook.ts

48
src/containers/Chats/components/show-doc-modal.component.tsx

@ -32,9 +32,42 @@ export const ShowDocModal: FC<IProps> = ({
const onClickUrl = (url: string): (() => void) => () => const onClickUrl = (url: string): (() => void) => () =>
donwloadWithoutOpenUrl(url); donwloadWithoutOpenUrl(url);
const isSupported = () => {
return [
"pdf",
"csv",
"xslx",
"docx",
"png",
"jpg",
"jpeg",
"bmp",
"mp4",
"webm",
"mp3",
].includes(docType);
};
const Content = useMemo(() => { const Content = useMemo(() => {
if (!docSrc || !docType) return null; if (!docSrc || !docType) return null;
if (!isSupported()) {
return (
<p
style={{
paddingTop: 40,
paddingBottom: 100,
textAlign: "center",
fontSize: 18,
}}
>
Предперегляд {'"'}
{docType}
{'"'} типу документа не передбачено в системі
</p>
);
}
if (docType.includes("pdf")) { if (docType.includes("pdf")) {
return ( return (
<object <object
@ -79,3 +112,18 @@ export const ShowDocModal: FC<IProps> = ({
</ModalComponent> </ModalComponent>
); );
}; };
// return (
// <>
// <iframe
// ref={iframeRef}
// src={`https://docs.google.com/gview?embedded=true&url=${encodeURIComponent(
// docSrc
// )}`}
// onLoad={(event) => {
// console.log(event.nativeEvent);
// }}
// style={{ width: "100%", height: "auto", border: "none" }}
// />
// </>
// );

19
src/containers/Chats/hooks/use-create-text-message.hook.ts

@ -45,6 +45,25 @@ export const useCreateTextMessage = ({
}, },
[setEditedMessage, setMessage] [setEditedMessage, setMessage]
); );
const onChangeChatId = () => {
const cached = localStorage.getItem(`newMessage${chatId}`);
console.log(cached);
if (cached) {
setMessage(cached);
} else setMessage("");
};
useEffect(() => {
if (message) localStorage.setItem(`newMessage${chatId}`, message);
else localStorage.removeItem(`newMessage${chatId}`);
}, [message]);
useEffect(() => {
onChangeChatId();
}, [chatId]);
const sendEditMessage = async () => { const sendEditMessage = async () => {
const dataSend = { const dataSend = {
newMessage: message, newMessage: message,

Loading…
Cancel
Save