Merge pull request #815 from mentalblank/register-as-default-magnet-handler
Magnet handler registration contextual links
This commit is contained in:
commit
75202ed5a9
2 changed files with 28 additions and 14 deletions
|
|
@ -148,18 +148,32 @@
|
||||||
class="button is-info"
|
class="button is-info"
|
||||||
type="button"
|
type="button"
|
||||||
(click)="registerMagnetHandler()"
|
(click)="registerMagnetHandler()"
|
||||||
[disabled]="!canRegisterMagnetHandler">
|
[disabled]="!canRegisterMagnetHandler"
|
||||||
|
>
|
||||||
<span>
|
<span>
|
||||||
{{ canRegisterMagnetHandler ? 'Register Handler' : 'Unavailable in This Browser' }}
|
{{ canRegisterMagnetHandler ? "Register Handler" : "Unavailable in This Browser" }}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p class="help">
|
<p class="help">
|
||||||
{{
|
@if (canRegisterMagnetHandler) {
|
||||||
canRegisterMagnetHandler
|
This will attempt to register the client as your browser's default handler for magnet links and automatically open
|
||||||
? "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."
|
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."
|
} @else {
|
||||||
}}
|
Magnet link registration is unavailable. Your
|
||||||
|
<a href="https://caniuse.com/mdn-api_navigator_registerprotocolhandler" target="_blank" rel="noopener noreferrer">
|
||||||
|
browser may not support this feature
|
||||||
|
</a>
|
||||||
|
, or the client is not being served in a
|
||||||
|
<a
|
||||||
|
href="https://developer.mozilla.org/en-US/docs/Glossary/Secure_Context/"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
secure context
|
||||||
|
</a>
|
||||||
|
.
|
||||||
|
}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,10 +145,10 @@ export class SettingsComponent implements OnInit {
|
||||||
|
|
||||||
public registerMagnetHandler(): void {
|
public registerMagnetHandler(): void {
|
||||||
try {
|
try {
|
||||||
navigator.registerProtocolHandler("magnet", `${window.location.origin}/add?magnet=%s`);
|
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.");
|
alert('Success! Your browser will now prompt you to confirm and add the client as the default handler for magnet links.');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert("Magnet link registration failed.");
|
alert('Magnet link registration failed.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue