using System.Threading.Tasks; using Kavita.API.Database; using Kavita.API.Services.Reading; using Kavita.Models.DTOs.Progress; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Kavita.Server.Controllers; /// /// For the Panels app explicitly /// public class PanelsController(IReaderService readerService, IUnitOfWork unitOfWork) : BaseApiController { /// /// Saves the progress of a given chapter. /// /// /// /// [HttpPost("save-progress")] public async Task SaveProgress(ProgressDto dto, [FromQuery] string apiKey) { await readerService.SaveReadingProgress(dto, UserId); return Ok(); } /// /// Gets the Progress of a given chapter /// /// /// /// The number of pages read, 0 if none read [HttpGet("get-progress")] public async Task> GetProgress(int chapterId, [FromQuery] string apiKey) { var progress = await unitOfWork.AppUserProgressRepository.GetUserProgressDtoAsync(chapterId, UserId); if (progress == null) return Ok(new ProgressDto() { PageNum = 0, ChapterId = chapterId, VolumeId = 0, SeriesId = 0, LibraryId = 0 }); return Ok(progress); } }