From f93109cc27d36249ec76377a6081da9526c83042 Mon Sep 17 00:00:00 2001 From: MentalBlank Date: Mon, 12 May 2025 01:38:45 +1000 Subject: [PATCH] Magnet link registration contextual links Replaced the static magnet handler help text shown when registration is unavailable (due to an insecure context or lack of browser support) with contextual HTML links. --- .../src/app/settings/settings.component.html | 36 +++++++++++++------ client/src/app/settings/settings.component.ts | 6 ++-- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/client/src/app/settings/settings.component.html b/client/src/app/settings/settings.component.html index 7b3c537..fc74881 100644 --- a/client/src/app/settings/settings.component.html +++ b/client/src/app/settings/settings.component.html @@ -144,22 +144,36 @@
-

- {{ - canRegisterMagnetHandler - ? "This will attempt to register the client as your browser's default handler for magnet links and automatically open them in the new torrent screen for downloading." - : "Magnet link registration is unavailable because either your browser does not support it or the client is not being served to you in a secure context." - }} + @if (canRegisterMagnetHandler) { + This will attempt to register the client as your browser's default handler for magnet links and automatically open + them in the new torrent screen for downloading. + } @else { + Magnet link registration is unavailable. Your + + browser may not support this feature + + , or the client is not being served in a + + secure context + + . + }

diff --git a/client/src/app/settings/settings.component.ts b/client/src/app/settings/settings.component.ts index 1d8f946..0ef3186 100644 --- a/client/src/app/settings/settings.component.ts +++ b/client/src/app/settings/settings.component.ts @@ -145,10 +145,10 @@ export class SettingsComponent implements OnInit { public registerMagnetHandler(): void { try { - navigator.registerProtocolHandler("magnet", `${window.location.origin}/add?magnet=%s`); - alert("Success! Your browser will now prompt you to confirm and add the client as the default handler for magnet links."); + navigator.registerProtocolHandler('magnet', `${window.location.origin}/add?magnet=%s`); + alert('Success! Your browser will now prompt you to confirm and add the client as the default handler for magnet links.'); } catch (error) { - alert("Magnet link registration failed."); + alert('Magnet link registration failed.'); } } }