import { Injectable, inject } from '@angular/core';
import { OfflineQueueRepository } from '../../infrastructure/offline-queue.repository';

@Injectable({ providedIn: 'root' })
export class OfflineMessageQueueService {
  private readonly repository = inject(OfflineQueueRepository);

  enqueue(ownerId: string, messageId: string): Promise<void> {
    return this.repository.enqueue(ownerId, messageId);
  }

  retryPending(ownerId: string): Promise<string[]> {
    return this.repository.load(ownerId);
  }

  markDelivered(ownerId: string, messageId: string): Promise<void> {
    return this.repository.remove(ownerId, messageId);
  }

  clear(ownerId: string): Promise<void> {
    return this.repository.clear(ownerId);
  }
}
