Function clearFailedOperations

  • Clears failed operations, optionally filtered by type.

    Parameters

    Returns void

    export function clearFailedOperations(type?: FailedOperationType): void {
    try {
    const queue = getFailedOperations();
    const initialLength = queue.operations.length;

    if (type) {
    queue.operations = queue.operations.filter((op) => op.type !== type);
    console.info(
    `[Storage] Cleared ${initialLength - queue.operations.length} failed ${type} operations`,
    );
    } else {
    queue.operations = [];
    console.info("[Storage] Cleared all failed operations");
    }

    queue.lastUpdated = Date.now();
    storage.setItem(STORAGE_KEYS.FAILED_OPERATIONS, JSON.stringify(queue));
    } catch (error) {
    console.error("[Storage] Failed to clear operations:", error);
    }
    }