refactoring, numbering plan
This commit is contained in:
1 parent
b5279434b2
commit
3b04039aa9
47 files changed
+3485
-953
No files matched your search
@@ -1,16 +1,37 @@
|
||||
let pendingFiles: File[] = [];
|
||||
/** Routes that can receive a handoff from another route. */
|
||||
export type PendingFileTarget = 'bea' | 'pagination';
|
||||
|
||||
type QueuedFile = { file: File; target: PendingFileTarget };
|
||||
|
||||
let queue: QueuedFile[] = [];
|
||||
|
||||
/**
|
||||
* In-memory handoff between routes (start page → beA workspace, merge →
|
||||
* pagination). Nothing is uploaded or persisted; the receiving route takes and
|
||||
* clears the queue on mount.
|
||||
* clears the files queued for its own target on mount.
|
||||
*
|
||||
* The target keeps a queued ZIP from being consumed — and silently dropped — by
|
||||
* a tool that only accepts PDFs.
|
||||
*/
|
||||
export const queuePendingFiles = (files: File[]) => {
|
||||
pendingFiles = [...pendingFiles, ...files];
|
||||
export const queuePendingFiles = (files: File[], target: PendingFileTarget) => {
|
||||
queue = [...queue, ...files.map((file) => ({ file, target }))];
|
||||
};
|
||||
|
||||
export const takePendingFiles = () => {
|
||||
const files = pendingFiles;
|
||||
pendingFiles = [];
|
||||
return files;
|
||||
/** Takes (and clears) the files queued for `target`; other targets stay queued. */
|
||||
export const takePendingFiles = (target: PendingFileTarget): File[] => {
|
||||
const taken: File[] = [];
|
||||
const remaining: QueuedFile[] = [];
|
||||
|
||||
for (const entry of queue) {
|
||||
if (entry.target === target) taken.push(entry.file);
|
||||
else remaining.push(entry);
|
||||
}
|
||||
|
||||
queue = remaining;
|
||||
return taken;
|
||||
};
|
||||
|
||||
/** Test/storybook helper: forget everything that is still queued. */
|
||||
export const clearPendingFiles = () => {
|
||||
queue = [];
|
||||
};
|
||||
Reference in new issue
Block a user