Simplify client downloads and add bulk selection

This commit is contained in:
2026-10-04 17:56:45 +03:00
parent 416fae33a2
commit fe4c716aa8
3 changed files with 261 additions and 109 deletions

View File

@@ -59,6 +59,11 @@ export interface ProofingContextType {
getFormattedList: () => string;
/** Selected asset tokens in album order — the payload for a ZIP download. */
getSelectedTokens: () => string[];
/** Number of assets in the current album. */
albumCount: number;
/** Select every asset, or clear everything when all are already selected. */
toggleSelectAll: () => void;
allowMailto: boolean;
/**
* `encodeEmail()` of the "email to photographer" recipient, when one is
@@ -284,6 +289,20 @@ export function ProofingProvider({
}
};
const toggleSelectAll = () => {
if (!sessionInit || submitted) return;
editSelection((prev) => {
const allSelected =
albumTokens.length > 0 &&
albumTokens.every((token) => prev.has(token));
return allSelected
? new Set<string>()
: new Set(albumTokens);
});
};
const getProofingUrl = () => {
if (albumTokens.length === 0 || favorites.size === 0) {
return typeof window !== 'undefined' ? window.location.href : '';
@@ -335,6 +354,8 @@ export function ProofingProvider({
getProofingUrl,
getFormattedList,
getSelectedTokens,
albumCount: albumTokens.length,
toggleSelectAll,
allowMailto,
encodedMailto,
downloadArchiveUrl,