um-react/src/util/DecryptionQueue.ts

14 lines
624 B
TypeScript
Raw Normal View History

2023-05-17 23:04:37 +00:00
import { DECRYPTION_WORKER_ACTION_NAME, DecryptionResult } from '~/decrypt-worker/constants';
2023-05-16 21:47:47 +00:00
import { ConcurrentQueue } from './ConcurrentQueue';
import { WorkerClientBus } from './WorkerEventBus';
2023-05-17 23:04:37 +00:00
export class DecryptionQueue extends ConcurrentQueue<{ id: string; blobURI: string }, DecryptionResult> {
2023-05-16 21:47:47 +00:00
constructor(private workerClientBus: WorkerClientBus<DECRYPTION_WORKER_ACTION_NAME>, maxQueue?: number) {
super(maxQueue);
}
2023-05-17 23:04:37 +00:00
async handler(item: { id: string; blobURI: string }): Promise<DecryptionResult> {
2023-05-16 21:47:47 +00:00
return this.workerClientBus.request(DECRYPTION_WORKER_ACTION_NAME.DECRYPT, item.blobURI);
}
}