11import { createCryptoBackend } from './crypto-backend.js'
22import { createProgressRing } from './progress.js'
3+ import { initUpload } from './upload.js'
34import { t } from './i18n.js'
45import {
56 newXFTPAgent , closeXFTPAgent ,
@@ -39,6 +40,7 @@ export function initDownload(app: HTMLElement, hash: string) {
3940 <div id="dl-progress" class="stage" hidden>
4041 <div id="dl-progress-container"></div>
4142 <p id="dl-status">${ t ( 'downloading' , 'Downloading\u2026' ) } </p>
43+ <a id="dl-upload-link" class="upload-link" hidden href="#">${ t ( 'uploadYourFile' , 'Upload your file' ) } </a>
4244 </div>
4345 <div id="dl-error" class="stage" hidden>
4446 <p class="error" id="dl-error-msg"></p>
@@ -54,6 +56,7 @@ export function initDownload(app: HTMLElement, hash: string) {
5456 const dlBtn = document . getElementById ( 'dl-btn' ) !
5557 const errorMsg = document . getElementById ( 'dl-error-msg' ) !
5658 const retryBtn = document . getElementById ( 'dl-retry-btn' ) !
59+ const uploadLink = document . getElementById ( 'dl-upload-link' ) !
5760
5861 function showStage ( stage : HTMLElement ) {
5962 for ( const s of [ readyStage , progressStage , errorStage ] ) s . hidden = true
@@ -72,6 +75,11 @@ export function initDownload(app: HTMLElement, hash: string) {
7275
7376 dlBtn . addEventListener ( 'click' , startDownload )
7477 retryBtn . addEventListener ( 'click' , ( ) => showStage ( readyStage ) )
78+ uploadLink . addEventListener ( 'click' , ( e ) => {
79+ e . preventDefault ( )
80+ history . replaceState ( null , '' , window . location . pathname )
81+ initUpload ( app )
82+ } )
7583
7684 async function startDownload ( ) {
7785 showStage ( progressStage )
@@ -132,6 +140,7 @@ export function initDownload(app: HTMLElement, hash: string) {
132140
133141 ring . update ( 1 )
134142 statusText . textContent = t ( 'downloadComplete' , 'Download complete' )
143+ uploadLink . hidden = false
135144 app . dispatchEvent ( new CustomEvent ( 'xftp:download-complete' , { detail : { fileName} , bubbles : true } ) )
136145 } catch ( err : any ) {
137146 const msg = err ?. message ?? String ( err )
0 commit comments