don't render expired uploads

This commit is contained in:
Danny Coates 2018-11-16 12:30:15 -08:00
parent 9989f944c3
commit 32a55d00b2
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
3 changed files with 26 additions and 12 deletions

View File

@ -18,6 +18,7 @@ module.exports = function(state, emit) {
}
const archives = state.storage.files
.filter(archive => !archive.expired)
.map(archive => archiveTile(state, emit, archive))
.reverse();

View File

@ -5,9 +5,9 @@ const modal = require('./modal');
const intro = require('./intro');
module.exports = function(state, emit) {
const archives = state.storage.files.map(archive =>
archiveTile(state, emit, archive)
);
const archives = state.storage.files
.filter(archive => !archive.expired)
.map(archive => archiveTile(state, emit, archive));
let left = '';
if (state.uploading) {
left = archiveTile.uploading(state, emit);
@ -23,11 +23,12 @@ module.exports = function(state, emit) {
: list(archives, 'list-reset h-full overflow-y-scroll', 'mb-3');
return html`
<main class="main relative">
${state.modal && modal(state, emit)}
<section class="h-full w-full p-6 md:flex md:flex-row z-10">
<div class="md:mr-6 md:w-1/2">${left}</div>
<div class="md:w-1/2 mt-6 md:mt-0">${right}</div>
</section>
</main>`;
<main class="main relative">
${state.modal && modal(state, emit)}
<section class="h-full w-full p-6 md:flex md:flex-row z-10">
<div class="md:mr-6 md:w-1/2">${left}</div>
<div class="md:w-1/2 mt-6 md:mt-0">${right}</div>
</section>
</main>
`;
};

View File

@ -184,8 +184,17 @@ async function streamToArrayBuffer(stream, size) {
}
function list(items, ulStyle = '', liStyle = '') {
const lis = items.map(i => html`<li class="${liStyle}">${i}</li>`);
return html`<ul class="${ulStyle}">${lis}</ul>`;
const lis = items.map(
i =>
html`
<li class="${liStyle}">${i}</li>
`
);
return html`
<ul class="${ulStyle}">
${lis}
</ul>
`;
}
function secondsToL10nId(seconds) {
@ -199,6 +208,9 @@ function secondsToL10nId(seconds) {
}
function timeLeft(milliseconds) {
if (milliseconds < 1) {
return { id: 'linkExpiredAlt' };
}
const minutes = Math.floor(milliseconds / 1000 / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);