Some ignored filles was missing
This commit is contained in:
parent
7db22245e2
commit
fd5ab6bc0d
268 changed files with 31970 additions and 4 deletions
96
wwwroot/js/storage/OperationQueue.js
Normal file
96
wwwroot/js/storage/OperationQueue.js
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
* Operation Queue Manager
|
||||
* Handles FIFO queue of pending sync operations
|
||||
*/
|
||||
export class OperationQueue {
|
||||
constructor(indexedDB) {
|
||||
this.indexedDB = indexedDB;
|
||||
}
|
||||
/**
|
||||
* Add operation to the end of the queue
|
||||
*/
|
||||
async enqueue(operation) {
|
||||
await this.indexedDB.addToQueue(operation);
|
||||
}
|
||||
/**
|
||||
* Get the first operation from the queue (without removing it)
|
||||
* Returns null if queue is empty
|
||||
*/
|
||||
async peek() {
|
||||
const queue = await this.indexedDB.getQueue();
|
||||
return queue.length > 0 ? queue[0] : null;
|
||||
}
|
||||
/**
|
||||
* Get all operations in the queue (sorted by timestamp FIFO)
|
||||
*/
|
||||
async getAll() {
|
||||
return await this.indexedDB.getQueue();
|
||||
}
|
||||
/**
|
||||
* Remove a specific operation from the queue
|
||||
*/
|
||||
async remove(operationId) {
|
||||
await this.indexedDB.removeFromQueue(operationId);
|
||||
}
|
||||
/**
|
||||
* Remove the first operation from the queue and return it
|
||||
* Returns null if queue is empty
|
||||
*/
|
||||
async dequeue() {
|
||||
const operation = await this.peek();
|
||||
if (operation) {
|
||||
await this.remove(operation.id);
|
||||
}
|
||||
return operation;
|
||||
}
|
||||
/**
|
||||
* Clear all operations from the queue
|
||||
*/
|
||||
async clear() {
|
||||
await this.indexedDB.clearQueue();
|
||||
}
|
||||
/**
|
||||
* Get the number of operations in the queue
|
||||
*/
|
||||
async size() {
|
||||
const queue = await this.getAll();
|
||||
return queue.length;
|
||||
}
|
||||
/**
|
||||
* Check if queue is empty
|
||||
*/
|
||||
async isEmpty() {
|
||||
const size = await this.size();
|
||||
return size === 0;
|
||||
}
|
||||
/**
|
||||
* Get operations for a specific event ID
|
||||
*/
|
||||
async getOperationsForEvent(eventId) {
|
||||
const queue = await this.getAll();
|
||||
return queue.filter(op => op.eventId === eventId);
|
||||
}
|
||||
/**
|
||||
* Remove all operations for a specific event ID
|
||||
*/
|
||||
async removeOperationsForEvent(eventId) {
|
||||
const operations = await this.getOperationsForEvent(eventId);
|
||||
for (const op of operations) {
|
||||
await this.remove(op.id);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Update retry count for an operation
|
||||
*/
|
||||
async incrementRetryCount(operationId) {
|
||||
const queue = await this.getAll();
|
||||
const operation = queue.find(op => op.id === operationId);
|
||||
if (operation) {
|
||||
operation.retryCount++;
|
||||
// Re-add to queue with updated retry count
|
||||
await this.remove(operationId);
|
||||
await this.enqueue(operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=OperationQueue.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue