diff --git a/external/lang b/external/lang index 8191f8301732d2863bb100a8839862c7d92294c3..ce5e32d444a35a691ac6b0abfbc722945e7cdf46 160000 --- a/external/lang +++ b/external/lang @@ -1 +1 @@ -Subproject commit 8191f8301732d2863bb100a8839862c7d92294c3 +Subproject commit ce5e32d444a35a691ac6b0abfbc722945e7cdf46 diff --git a/src/components/common/messaging/attachments/Attachment.module.scss b/src/components/common/messaging/attachments/Attachment.module.scss index b52e1ca7214006654a540ec9f0983d5d6e321bce..b3253ae31cd10ea94a234cc132131078f7ebe3b0 100644 --- a/src/components/common/messaging/attachments/Attachment.module.scss +++ b/src/components/common/messaging/attachments/Attachment.module.scss @@ -111,16 +111,16 @@ .actions.imageAction { grid-template: - "name icon download" auto - "size icon download" auto + "name icon external download" auto + "size icon external download" auto / minmax(20px, 1fr) min-content min-content; } .actions { display: grid; grid-template: - "icon name download" auto - "icon size download" auto + "icon name external download" auto + "icon size external download" auto / min-content minmax(20px, 1fr) min-content; align-items: center; @@ -150,6 +150,10 @@ grid-area: download; } + .externalType { + grid-area: external; + } + .iconType { grid-area: icon; } diff --git a/src/components/common/messaging/attachments/AttachmentActions.tsx b/src/components/common/messaging/attachments/AttachmentActions.tsx index c551d2bd0618a28631e6d41a3706f329480e2480..8ca55cfe75d18c841cb433b232a4f1a0c66d9078 100644 --- a/src/components/common/messaging/attachments/AttachmentActions.tsx +++ b/src/components/common/messaging/attachments/AttachmentActions.tsx @@ -100,6 +100,14 @@ export default function AttachmentActions({ attachment }: Props) { <File size={24} className={styles.iconType} /> <span className={styles.filename}>{filename}</span> <span className={styles.filesize}>{filesize}</span> + { metadata.type === 'Text' && <a + href={open_url} + target="_blank" + className={styles.externalType}> + <IconButton> + <LinkExternal size={24} /> + </IconButton> + </a> } <a href={download_url} className={styles.downloadIcon} diff --git a/src/components/common/messaging/attachments/TextFile.tsx b/src/components/common/messaging/attachments/TextFile.tsx index f8ad00ef8cba6c11140a456ea74f835572cbf8ef..d14bf75d1f75c466662545c5e07ad7344ac303c9 100644 --- a/src/components/common/messaging/attachments/TextFile.tsx +++ b/src/components/common/messaging/attachments/TextFile.tsx @@ -29,6 +29,12 @@ export default function TextFile({ attachment }: Props) { useEffect(() => { if (typeof content !== "undefined") return; if (loading) return; + + if (attachment.size > 20_000) { + setContent('This file is > 20 KB, for your sake I did not load it.\nSee tracking issue here for previews: https://gitlab.insrt.uk/revolt/revite/-/issues/2'); + return; + } + setLoading(true); let cached = fileCache[attachment._id]; @@ -37,7 +43,7 @@ export default function TextFile({ attachment }: Props) { setLoading(false); } else { axios - .get(url) + .get(url, { transformResponse: [] }) .then((res) => { setContent(res.data); fileCache[attachment._id] = res.data; diff --git a/src/lib/TextAreaAutoSize.tsx b/src/lib/TextAreaAutoSize.tsx index 5660dedfa9e030344c8bb2c0d83f45e606718733..b90633183ae61081457f12146d0c2aeb4de2eba2 100644 --- a/src/lib/TextAreaAutoSize.tsx +++ b/src/lib/TextAreaAutoSize.tsx @@ -131,7 +131,7 @@ export default function TextAreaAutoSize(props: TextAreaAutoSizeProps) { ref={ref} value={value} padding={padding} - style={{ height: minHeight }} + style={{ minHeight }} hideBorder={hideBorder} lineHeight={lineHeight} onChange={(ev) => {