mirror of
https://git.v0l.io/Kieran/void.cat.git
synced 2025-09-26 13:26:14 +02:00
Fix text previews
This commit is contained in:
@@ -3,4 +3,5 @@
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
text-align: initial;
|
text-align: initial;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
@@ -5,15 +5,24 @@ export function TextPreview(props) {
|
|||||||
let [content, setContent] = useState("Loading..");
|
let [content, setContent] = useState("Loading..");
|
||||||
|
|
||||||
async function getContent(link) {
|
async function getContent(link) {
|
||||||
let req = await fetch(link);
|
let req = await fetch(`${link}?t=${new Date().getTime()}`, {
|
||||||
|
headers: {
|
||||||
|
"pragma": "no-cache",
|
||||||
|
"cache-control": "no-cache"
|
||||||
|
}
|
||||||
|
});
|
||||||
if (req.ok) {
|
if (req.ok) {
|
||||||
setContent(await req.text());
|
setContent(await req.text());
|
||||||
|
} else {
|
||||||
|
setContent("ERROR :(")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getContent(props.link);
|
if (props.link !== undefined && props.link !== "#") {
|
||||||
}, []);
|
getContent(props.link);
|
||||||
|
}
|
||||||
|
}, [props.link]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<pre className="text-preview">{content}</pre>
|
<pre className="text-preview">{content}</pre>
|
||||||
|
Reference in New Issue
Block a user