Fix large text files not loading properly
This commit is contained in:
@@ -70,7 +70,7 @@ const toggle_play = () => playing ? player.pause() : player.play()
|
|||||||
</button>
|
</button>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
|
||||||
{#if !audio_reload}
|
{#if file.id && !audio_reload}
|
||||||
<!-- svelte-ignore a11y-media-has-caption -->
|
<!-- svelte-ignore a11y-media-has-caption -->
|
||||||
<audio
|
<audio
|
||||||
bind:this={player}
|
bind:this={player}
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import { tick } from "svelte";
|
||||||
|
|
||||||
|
|
||||||
let container
|
let container
|
||||||
let text_type = ""
|
let text_type = ""
|
||||||
|
|
||||||
@@ -15,8 +18,9 @@ export const set_file = file => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let md_container
|
let md_container
|
||||||
const markdown = file => {
|
const markdown = async file => {
|
||||||
text_type = "markdown"
|
text_type = "markdown"
|
||||||
|
await tick()
|
||||||
|
|
||||||
fetch("/u/" + file.id + "/preview").then(resp => {
|
fetch("/u/" + file.id + "/preview").then(resp => {
|
||||||
if (!resp.ok) { return Promise.reject(resp.status) }
|
if (!resp.ok) { return Promise.reject(resp.status) }
|
||||||
@@ -29,8 +33,9 @@ const markdown = file => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let text_pre
|
let text_pre
|
||||||
const text = file => {
|
const text = async file => {
|
||||||
text_type = "text"
|
text_type = "text"
|
||||||
|
await tick()
|
||||||
|
|
||||||
if (file.size > 1 << 22) { // File larger than 4 MiB
|
if (file.size > 1 << 22) { // File larger than 4 MiB
|
||||||
text_pre.innerText = "File is too large to view online.\nPlease download and view it locally."
|
text_pre.innerText = "File is too large to view online.\nPlease download and view it locally."
|
||||||
@@ -49,8 +54,9 @@ const text = file => {
|
|||||||
|
|
||||||
let code_pre
|
let code_pre
|
||||||
let prettyprint = false
|
let prettyprint = false
|
||||||
const code = file => {
|
const code = async file => {
|
||||||
text_type = "code"
|
text_type = "code"
|
||||||
|
await tick()
|
||||||
|
|
||||||
if (file.size > 1 << 22) { // File larger than 4 MiB
|
if (file.size > 1 << 22) { // File larger than 4 MiB
|
||||||
code_pre.innerText = "File is too large to view online.\nPlease download and view it locally."
|
code_pre.innerText = "File is too large to view online.\nPlease download and view it locally."
|
||||||
|
Reference in New Issue
Block a user