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:
Paul
2021-07-06 14:58:54 +01:00
parent aebcf2875a
commit 7b9766cb0b
5 changed files with 25 additions and 7 deletions

View File

@@ -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;