forked from Kieran/void.cat
show magnet/torrent links
This commit is contained in:
parent
c7bc3c50f7
commit
78997071a1
@ -44,7 +44,7 @@ export function FilePreview() {
|
|||||||
function isPaymentRequired() {
|
function isPaymentRequired() {
|
||||||
return info?.payment?.required === true && !order;
|
return info?.payment?.required === true && !order;
|
||||||
}
|
}
|
||||||
|
|
||||||
function canAccessFile() {
|
function canAccessFile() {
|
||||||
if (isPaymentRequired()) {
|
if (isPaymentRequired()) {
|
||||||
return false;
|
return false;
|
||||||
@ -82,11 +82,11 @@ export function FilePreview() {
|
|||||||
return new window.TransformStream({
|
return new window.TransformStream({
|
||||||
transform: (chunk, controller) => {
|
transform: (chunk, controller) => {
|
||||||
update(chunk.length);
|
update(chunk.length);
|
||||||
controller.enqueue(chunk);
|
controller.enqueue(chunk);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderEncryptedDownload() {
|
function renderEncryptedDownload() {
|
||||||
if (!isFileEncrypted() || isDecrypted() || isPaymentRequired()) return;
|
if (!isFileEncrypted() || isDecrypted() || isPaymentRequired()) return;
|
||||||
return (
|
return (
|
||||||
@ -214,7 +214,7 @@ export function FilePreview() {
|
|||||||
if (info) {
|
if (info) {
|
||||||
let fileLink = info.metadata?.url ?? `${ApiHost}/d/${info.id}`;
|
let fileLink = info.metadata?.url ?? `${ApiHost}/d/${info.id}`;
|
||||||
setFileSize(info.metadata.size);
|
setFileSize(info.metadata.size);
|
||||||
|
|
||||||
let order = window.localStorage.getItem(`payment-${info.id}`);
|
let order = window.localStorage.getItem(`payment-${info.id}`);
|
||||||
if (order) {
|
if (order) {
|
||||||
let orderObj = JSON.parse(order);
|
let orderObj = JSON.parse(order);
|
||||||
@ -242,9 +242,24 @@ export function FilePreview() {
|
|||||||
{info.uploader ? <InlineProfile profile={info.uploader}/> : null}
|
{info.uploader ? <InlineProfile profile={info.uploader}/> : null}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{canAccessFile() ?
|
{canAccessFile() &&
|
||||||
<a className="btn" href={link}
|
<>
|
||||||
download={info.metadata?.name ?? info.id}>Download</a> : null}
|
|
||||||
|
<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>
|
||||||
</div>
|
</div>
|
||||||
{renderPayment()}
|
{renderPayment()}
|
||||||
|
@ -97,4 +97,8 @@ pre.copy {
|
|||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mr10 {
|
||||||
|
margin-right: 10px;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user