Audio previews

This commit is contained in:
May 2023-08-01 13:36:14 +00:00
parent eb6d06cf25
commit f43162abef
3 changed files with 10 additions and 4 deletions

View file

@ -166,9 +166,13 @@ app.get("/download/:fileId",(req,res) => {
: ( : (
file.mime.startsWith("video/") file.mime.startsWith("video/")
? `<div style="min-height:10px"></div><video src="/file/${req.params.fileId}" controls></video>` ? `<div style="min-height:10px"></div><video src="/file/${req.params.fileId}" controls></video>`
: (
file.mime.startsWith("audio/")
? `<div style="min-height:10px"></div><audio src="/file/${req.params.fileId}" controls></audio>`
: "" : ""
) )
) )
)
.replace(/\$Uploader/g,!file.owner||file.visibility=="anonymous" ? "Anonymous" : `@${Accounts.getFromId(file.owner)?.username || "Deleted User"}`) .replace(/\$Uploader/g,!file.owner||file.visibility=="anonymous" ? "Anonymous" : `@${Accounts.getFromId(file.owner)?.username || "Deleted User"}`)
) )
}) })

View file

@ -20,7 +20,7 @@
} }
#uploadWindow { #uploadWindow {
img, video { img, video, audio {
width:100%; width:100%;
} }
} }

View file

@ -8,6 +8,7 @@
import OptionPicker from "../prompts/OptionPicker.svelte"; import OptionPicker from "../prompts/OptionPicker.svelte";
let picker; let picker;
let query = "";
fetchFilePointers(); fetchFilePointers();
</script> </script>
@ -25,10 +26,11 @@
</div> </div>
{:else} {:else}
<div class="loggedIn"> <div class="loggedIn">
<input type="text" placeholder={`Search ${$files.length} file(s)`} class="searchBar"> <input type="text" placeholder={`Search ${$files.length} file(s)`} class="searchBar" bind:value={query}>
<div class="fileList"> <div class="fileList">
{#each $files as file (file.id)} <!-- Probably wildly inefficient but who cares, I just wanna get this over with -->
{#each $files.filter(f => f.name.toLowerCase().includes(query.toLowerCase()) || f.id.toLowerCase().includes(query.toLowerCase()) || f.tag.includes(query.toLowerCase())) as file (file.id)}
<div class="flFile" transition:fade={{duration:200}} animate:flip={{duration:200}}> <div class="flFile" transition:fade={{duration:200}} animate:flip={{duration:200}}>
<button class="hitbox" on:click={window.open(`/download/${file.id}`)}></button> <!-- this is bad, but I'm lazy --> <button class="hitbox" on:click={window.open(`/download/${file.id}`)}></button> <!-- this is bad, but I'm lazy -->
<div class="flexCont"> <div class="flexCont">