mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-25 23:22:06 -05:00
Fix: Use minHeight.
Temporary change: Prevent TextFile from loading large content. Fixes #1: File preview failing with JSON files. Add a way to open text files in new tab.
This commit is contained in:
parent
aebcf2875a
commit
7b9766cb0b
5 changed files with 25 additions and 7 deletions
2
external/lang
vendored
2
external/lang
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 8191f8301732d2863bb100a8839862c7d92294c3
|
Subproject commit ce5e32d444a35a691ac6b0abfbc722945e7cdf46
|
|
@ -111,16 +111,16 @@
|
||||||
|
|
||||||
.actions.imageAction {
|
.actions.imageAction {
|
||||||
grid-template:
|
grid-template:
|
||||||
"name icon download" auto
|
"name icon external download" auto
|
||||||
"size icon download" auto
|
"size icon external download" auto
|
||||||
/ minmax(20px, 1fr) min-content min-content;
|
/ minmax(20px, 1fr) min-content min-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
.actions {
|
.actions {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template:
|
grid-template:
|
||||||
"icon name download" auto
|
"icon name external download" auto
|
||||||
"icon size download" auto
|
"icon size external download" auto
|
||||||
/ min-content minmax(20px, 1fr) min-content;
|
/ min-content minmax(20px, 1fr) min-content;
|
||||||
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -150,6 +150,10 @@
|
||||||
grid-area: download;
|
grid-area: download;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.externalType {
|
||||||
|
grid-area: external;
|
||||||
|
}
|
||||||
|
|
||||||
.iconType {
|
.iconType {
|
||||||
grid-area: icon;
|
grid-area: icon;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,14 @@ export default function AttachmentActions({ attachment }: Props) {
|
||||||
<File size={24} className={styles.iconType} />
|
<File size={24} className={styles.iconType} />
|
||||||
<span className={styles.filename}>{filename}</span>
|
<span className={styles.filename}>{filename}</span>
|
||||||
<span className={styles.filesize}>{filesize}</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
|
<a
|
||||||
href={download_url}
|
href={download_url}
|
||||||
className={styles.downloadIcon}
|
className={styles.downloadIcon}
|
||||||
|
|
|
@ -29,6 +29,12 @@ export default function TextFile({ attachment }: Props) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof content !== "undefined") return;
|
if (typeof content !== "undefined") return;
|
||||||
if (loading) 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);
|
setLoading(true);
|
||||||
|
|
||||||
let cached = fileCache[attachment._id];
|
let cached = fileCache[attachment._id];
|
||||||
|
@ -37,7 +43,7 @@ export default function TextFile({ attachment }: Props) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
} else {
|
} else {
|
||||||
axios
|
axios
|
||||||
.get(url)
|
.get(url, { transformResponse: [] })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setContent(res.data);
|
setContent(res.data);
|
||||||
fileCache[attachment._id] = res.data;
|
fileCache[attachment._id] = res.data;
|
||||||
|
|
|
@ -131,7 +131,7 @@ export default function TextAreaAutoSize(props: TextAreaAutoSizeProps) {
|
||||||
ref={ref}
|
ref={ref}
|
||||||
value={value}
|
value={value}
|
||||||
padding={padding}
|
padding={padding}
|
||||||
style={{ height: minHeight }}
|
style={{ minHeight }}
|
||||||
hideBorder={hideBorder}
|
hideBorder={hideBorder}
|
||||||
lineHeight={lineHeight}
|
lineHeight={lineHeight}
|
||||||
onChange={(ev) => {
|
onChange={(ev) => {
|
||||||
|
|
Loading…
Reference in a new issue