Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.
C# annotationscbzcomicinfocomicscomics-readercross-platformcsharpepubepub-readerfreelinuxmangamedia-servermetadataopdsopds-feedpdfself-hostedubooquitywindows
Implemented the ability to move between volumes (reading) automatically without existing the app. (#198)
Joseph Milazzod92e9e7602b5
diff --git a/API/Controllers/ReaderController.cs b/API/Controllers/ReaderController.csindex e3927146b..020e67c0b 100644--- a/API/Controllers/ReaderController.cs+++ b/API/Controllers/ReaderController.cs@@ -239,5 +239,80 @@ namespace API.Controllersreturn BadRequest("Could not save progress");}++ /// <summary>+ /// Returns the next logical volume from the series.+ /// </summary>+ /// <param name="seriesId"></param>+ /// <param name="volumeId"></param>+ /// <param name="currentChapterId"></param>+ /// <returns>chapter id for next manga</returns>+ [HttpGet("next-chapter")]+ public async Task<ActionResult<int>> GetNextChapter(int seriesId, int volumeId, int currentChapterId)+ {+ var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());+ var volumes = await _unitOfWork.SeriesRepository.GetVolumesDtoAsync(seriesId, user.Id);+ var currentVolume = await _unitOfWork.SeriesRepository.GetVolumeAsync(volumeId);++ var next = false;+ if (currentVolume.Number == 0)+ {+ foreach (var chapter in currentVolume.Chapters)+ {+ if (next)+ {+ return Ok(chapter.Id);+ }+ if (currentChapterId == chapter.Id) next = true;+ }+ }++ foreach (var volume in volumes)+ {+ if (volume.Number == currentVolume.Number + 1)+ {+ return Ok(volume.Chapters.FirstOrDefault()?.Id);+ }+ }+ return Ok(-1);+ }++ /// <summary>+ /// Returns the previous logical volume from the series.+ /// </summary>+ /// <param name="seriesId"></param>+ /// <param name="volumeId"></param>+ /// <returns>chapter id for next manga</returns>+ [HttpGet("prev-chapter")]+ public async Task<ActionResult<int>> GetPreviousChapter(int seriesId, int volumeId, int currentChapterId)+ {+ var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());+ var volumes = await _unitOfWork.SeriesRepository.GetVolumesDtoAsync(seriesId, user.Id);+ var currentVolume = await _unitOfWork.SeriesRepository.GetVolumeAsync(volumeId);++ var next = false;+ if (currentVolume.Number == 0)+ {+ var chapters = currentVolume.Chapters.Reverse();+ foreach (var chapter in chapters)+ {+ if (next)+ {+ return Ok(chapter.Id);+ }+ if (currentChapterId == chapter.Id) next = true;+ }+ }++ foreach (var volume in volumes.Reverse())+ {+ if (volume.Number == currentVolume.Number - 1)+ {+ return Ok(volume.Chapters.LastOrDefault()?.Id);+ }+ }+ return Ok(-1);+ }+}}\ No newline at end of filediff --git a/API/Controllers/SeriesController.cs b/API/Controllers/SeriesController.csindex 01737dfef..caa69b15f 100644--- a/API/Controllers/SeriesController.cs+++ b/API/Controllers/SeriesController.cs@@ -1,4 +1,5 @@using System.Collections.Generic;+using System.Linq;using System.Threading.Tasks;using API.DTOs;using API.Entities;@@ -89,18 +90,7 @@ namespace API.Controllersreturn Ok(await _unitOfWork.VolumeRepository.GetChapterDtoAsync(chapterId));}- /// <summary>- /// Returns the next logical volume from the series.- /// </summary>- /// <param name="seriesId"></param>- /// <param name="volumeId"></param>- /// <returns>chapter id for next manga</returns>- [HttpGet("next-volume")]- public async Task<ActionResult<int>> GetNextChapter(int seriesId, int volumeId)- {-- return Ok();- }+[HttpPost("update-rating")]