frontend: Highlight files not downloaded
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2025-03-29 14:45:06 +01:00
parent 0f2dafa3b1
commit 4973f7ac4a
2 changed files with 28 additions and 2 deletions

View file

@ -9,6 +9,7 @@
ListGroupItem,
} from '@sveltestrap/sveltestrap';
import { hasDownloaded } from '$lib/stores/downloaded.js';
import FileSize from './FileSize.svelte';
export let files = [];
@ -27,8 +28,8 @@
</CardBody>
<ListGroup flush class="border-secondary">
{#each files as file, index}
<ListGroupItem tag="a" href={file.path} target={(file.name.endsWith(".txt") || file.name.endsWith(".xml") || file.name.endsWith(".jpg") || file.name.endsWith(".png") || file.name.endsWith(".pdf"))?"_blank":"_self"} class="d-flex">
<h1 class="me-3">
<ListGroupItem tag="a" href={file.path} target={(file.name.endsWith(".txt") || file.name.endsWith(".xml") || file.name.endsWith(".jpg") || file.name.endsWith(".png") || file.name.endsWith(".pdf"))?"_blank":"_self"} class="d-flex" action on:click={() => hasDownloaded.update((u) => {u[file.path] = true; return u;})}>
<h1 class="me-3" class:text-info={!$hasDownloaded[file.path]}>
<Icon name="arrow-down-circle" />
</h1>
<div style="min-width: 0">

View file

@ -0,0 +1,25 @@
import { writable } from 'svelte/store';
function createDownloadedStore() {
let init = { };
try {
if (window.localStorage && window.localStorage.getItem("downloadedStore")) {
init = JSON.parse(window.localStorage.getItem("downloadedStore"));
}
} catch {
init = { };
}
const { subscribe, set, update } = writable(init);
return {
subscribe,
update: (u) => {
update(u);
if (window.localStorage) localStorage.setItem("downloadedStore", JSON.stringify(init));
},
}
}
export const hasDownloaded = createDownloadedStore();