Add resumable downloads, download paths, queue controls and history
This commit is contained in:
1 parent
434f6441da
commit
6027cfabb9
43 files changed
+2138
-291
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { element } from "./dom.js";
|
||||
import { formatDate } from "./format.js";
|
||||
|
||||
const maxRecentPaths = 5;
|
||||
|
||||
export function recentDestinations(entries) {
|
||||
const paths = [];
|
||||
for (const entry of entries) {
|
||||
if (!paths.includes(entry.destination)) paths.push(entry.destination);
|
||||
if (paths.length >= maxRecentPaths) break;
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
export function renderHistory(elements, entries) {
|
||||
elements.title.textContent = entries.length > 0 ? `History (${entries.length})` : "History";
|
||||
elements.empty.hidden = entries.length > 0;
|
||||
elements.clearButton.hidden = entries.length === 0;
|
||||
elements.list.replaceChildren(...entries.map(renderEntry));
|
||||
}
|
||||
|
||||
function renderEntry(entry) {
|
||||
const item = element("li", "history-item");
|
||||
const items = entry.items || [];
|
||||
const itemText = items.length === 1 ? items[0] : `${items.length} items`;
|
||||
item.append(
|
||||
element("div", "history-name", entry.fileName || itemText),
|
||||
element("p", "history-meta muted", `${itemText} moved to ${entry.destination}`),
|
||||
element("p", "history-meta muted", formatDate(entry.movedAt)),
|
||||
);
|
||||
if (entry.sourceUrl) item.append(element("p", "history-meta muted", entry.sourceUrl));
|
||||
return item;
|
||||
}
|
||||
Reference in new issue
Block a user