Add server overload warning to file preview section

This commit is contained in:
2025-01-31 23:07:10 +01:00
parent 5146acaa59
commit f9b330d4d1
3 changed files with 17 additions and 13 deletions

View File

@@ -1,7 +1,5 @@
<script>
import { onMount } from "svelte"
import { formatDataVolume } from "../util/Formatting.svelte";
import { stats } from "../lib/StatsSocket.js"
let ad_type = ""
@@ -21,17 +19,7 @@ onMount(() => {
})
</script>
{#if $stats.limits_init && $stats.limits.server_overload}
<div class="highlight_yellow" style="margin: 3px;">
Pixeldrain's servers are currently overloaded. In order to ensure
stability for our paying customers the free download limit has been
temporarily reduced to {formatDataVolume($stats.limits.transfer_limit,
3)}. If you want fast downloads, please return later when peak hours are
over.
</div>
{:else if ad_type === "patreon_support"}
{#if ad_type === "patreon_support"}
<div class="banner support_banner">
<span style="display: block; margin-bottom: 2px;">

View File

@@ -20,6 +20,8 @@ let file = {
<FileTitle title={file.name}/>
<slot></slot>
<IconBlock icon_href={file.icon_href}>
Type: {file.mime_type}<br/>
Size: {formatDataVolume(file.size, 3)}<br/>

View File

@@ -14,6 +14,7 @@ import Torrent from "./Torrent.svelte";
import { stats } from "../../lib/StatsSocket.js"
import Zip from "./Zip.svelte";
import SlowDown from "../../layout/SlowDown.svelte";
import TextBlock from "../../layout/TextBlock.svelte";
let viewer
let viewer_type = "loading"
@@ -32,6 +33,8 @@ export const set_file = async file => {
file.availability === "ip_download_limited_captcha_required"
) {
viewer_type = "rate_limit"
} else if (file.availability === "server_overload_captcha_required") {
viewer_type = "overload"
} else {
viewer_type = file_type(file)
}
@@ -75,6 +78,17 @@ export const seek = delta => {
file_type={current_file.mime_type}
icon_href={current_file.icon_href}
/>
{:else if viewer_type === "overload"}
<File bind:this={viewer} on:download on:reload>
<TextBlock><div class="highlight_yellow">
<p>
Pixeldrain's servers are currently overloaded. There are too
many people downloading too many things. In order to ensure
stability for our paying customers, free users are asked to
complete a CAPTCHA before starting a new download.
</p>
</div></TextBlock>
</File>
{:else if viewer_type === "rate_limit"}
<RateLimit bind:this={viewer} on:download></RateLimit>
{:else if viewer_type === "image"}