mirror of
https://git.um-react.app/um/um-react.git
synced 2026-11-25 14:56:58 +00:00
- Added a new `actions.ts` file defining `WorkerActionMap` for better type management of worker actions. - Updated `client.ts`, `worker.ts`, and `decrypt.ts` to utilize the new action types, enhancing type safety. - Refactored `DecryptCommandPayload` to rename `id` to `fileId` for clarity and consistency. - Adjusted various components to align with the new payload structure and improved error handling in the worker event bus. - Enhanced tests to ensure compatibility with the new action type definitions and payload structures.
20 lines
735 B
TypeScript
20 lines
735 B
TypeScript
import type { WorkerActionMap } from '~/decrypt-worker/actions';
|
|
import type { DecryptCommandPayload } from '~/decrypt-worker/types';
|
|
import { DECRYPTION_WORKER_ACTION_NAME, type DecryptionResult } from '~/decrypt-worker/constants';
|
|
|
|
import { ConcurrentQueue } from './ConcurrentQueue';
|
|
import { WorkerClientBus } from './WorkerEventBus';
|
|
|
|
export class DecryptionQueue extends ConcurrentQueue<DecryptCommandPayload, DecryptionResult> {
|
|
constructor(
|
|
private workerClientBus: WorkerClientBus<WorkerActionMap>,
|
|
maxQueue?: number,
|
|
) {
|
|
super(maxQueue);
|
|
}
|
|
|
|
async handler(item: DecryptCommandPayload): Promise<DecryptionResult> {
|
|
return this.workerClientBus.request(DECRYPTION_WORKER_ACTION_NAME.DECRYPT, item);
|
|
}
|
|
}
|