Simplify client downloads and add bulk selection
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user