fix: adds warning for torrentio rate limit

This commit is contained in:
2025-06-19 23:08:08 -05:00
parent 2121466322
commit fca189648b
6 changed files with 20 additions and 6 deletions

View File

@@ -15,6 +15,18 @@
}
}
@layer components {
.alert {
@apply text-white text-sm min-w-[250px] border px-4 py-3 rounded-md
}
.alert-success {
@apply bg-green-950 hover:bg-green-900 border-green-500
}
.alert-warning {
@apply bg-yellow-500/70 hover:bg-yellow-600 border-yellow-400 text-black
}
}
/* Prevent scrolling while dialog is open */
body:has(dialog[data-dialog-target="dialog"][open]) {
overflow: hidden;

View File

@@ -62,6 +62,7 @@ final class TorrentioController extends AbstractController
]);
});
} catch (TorrentioRateLimitException $exception) {
$this->broadcaster->alert('Warning', 'Torrentio has rate limited your requests. Please wait a few minutes before trying again.', 'warning');
return $this->render('bare.html.twig',
[],
new Response('Too many requests',

View File

@@ -17,7 +17,7 @@ readonly class Broadcaster
private RequestStack $requestStack,
) {}
public function alert(string $title, string $message): void
public function alert(string $title, string $message, string $type = "success"): void
{
$userAlertTopic = $this->requestStack->getCurrentRequest()->getSession()->get('mercure_alert_topic');
$update = new Update(
@@ -26,6 +26,7 @@ readonly class Broadcaster
'alert_id' => uniqid(),
'title' => $title,
'message' => $message,
'type' => $type,
])
);
$this->hub->publish($update);

View File

@@ -13,6 +13,8 @@ module.exports = {
"bg-orange-400",
"bg-blue-600",
"bg-rose-600",
"alert-success",
"alert-warning",
"min-w-64",
"rotate-180",
"-rotate-180",

View File

@@ -1,5 +1,5 @@
<turbo-stream action="prepend" target="alert_list">
<template>
<twig:Alert :title="title|default('')" :message="message" :alert_id="alert_id" data-controller="alert" />
<twig:Alert :title="title|default('')" :message="message" :alert_id="alert_id" type="{{ type|default('success') }}" data-controller="alert" />
</template>
</turbo-stream>

View File

@@ -1,7 +1,5 @@
<li {{ attributes }} id="alert_{{ alert_id }}" class="
text-white bg-green-950 text-sm min-w-[250px]
hover:bg-green-900 border border-green-500 px-4 py-3
rounded-md"
<li {{ attributes }} id="alert_{{ alert_id }}"
class="alert alert-{{ type|default('success') }}"
role="alert"
>
<div class="flex items-center">