const html = require('choo/html'); const assets = require('../../common/assets'); const notFound = require('./notFound'); const { allowedCopy, delay, fadeOut } = require('../utils'); module.exports = function(state, emit) { const file = state.storage.getFileById(state.params.id); if (!file) { return notFound(state, emit); } const div = html` `; async function sendNew(e) { e.preventDefault(); await fadeOut('share-link'); emit('pushState', '/'); } async function copyLink() { if (allowedCopy()) { emit('copy', { url: file.url, location: 'success-screen' }); const copyBtn = document.getElementById('copy-btn'); copyBtn.disabled = true; copyBtn.replaceChild( html``, copyBtn.firstChild ); await delay(2000); copyBtn.disabled = false; copyBtn.textContent = state.translate('copyUrlFormButton'); } } async function deleteFile() { emit('delete', { file, location: 'success-screen' }); await fadeOut('share-link'); emit('pushState', '/'); } return div; };