show magnet/torrent links

This commit is contained in:
Kieran 2023-03-24 22:28:50 +00:00
parent c7bc3c50f7
commit 78997071a1
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 26 additions and 7 deletions

View File

@ -44,7 +44,7 @@ export function FilePreview() {
function isPaymentRequired() {
return info?.payment?.required === true && !order;
}
function canAccessFile() {
if (isPaymentRequired()) {
return false;
@ -82,11 +82,11 @@ export function FilePreview() {
return new window.TransformStream({
transform: (chunk, controller) => {
update(chunk.length);
controller.enqueue(chunk);
controller.enqueue(chunk);
}
});
}
function renderEncryptedDownload() {
if (!isFileEncrypted() || isDecrypted() || isPaymentRequired()) return;
return (
@ -214,7 +214,7 @@ export function FilePreview() {
if (info) {
let fileLink = info.metadata?.url ?? `${ApiHost}/d/${info.id}`;
setFileSize(info.metadata.size);
let order = window.localStorage.getItem(`payment-${info.id}`);
if (order) {
let orderObj = JSON.parse(order);
@ -242,9 +242,24 @@ export function FilePreview() {
{info.uploader ? <InlineProfile profile={info.uploader}/> : null}
</div>
<div>
{canAccessFile() ?
<a className="btn" href={link}
download={info.metadata?.name ?? info.id}>Download</a> : null}
{canAccessFile() &&
<>
<a className="btn" href={info?.metadata?.magnetLink}>
<FeatherIcon icon="link" size="14px" className="mr10"/>
Magnet
</a>
<a className="btn" href={`${link}.torrent`}
download={info.metadata?.name ?? info.id}>
<FeatherIcon icon="file" size="14px" className="mr10"/>
Torrent
</a>
<a className="btn" href={link}
download={info.metadata?.name ?? info.id}>
<FeatherIcon icon="download" size="14px" className="mr10"/>
Direct Download
</a>
</>}
</div>
</div>
{renderPayment()}

View File

@ -97,4 +97,8 @@ pre.copy {
border-radius: 4px;
border: 1px solid;
padding: 5px;
}
.mr10 {
margin-right: 10px;
}