From b197f6f334a4fa9e537a14bdcf5a331b48f68893 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Mon, 11 Oct 2021 16:32:56 -0700 Subject: [PATCH] Release Shakeout (#655) * Cleaned up some code. Fixed an issue on books with good table of contents not allowing line tracking (progress) from being saved. Changed Save to Defaults on light mode to be primary. * Fixed a bug where deleting reading items would not actually delete them * Fixed a bug where after ordering reading lists then deleting the order would be undone (develop) * Code cleanup --- API.Tests/Parser/ComicParserTests.cs | 9 ++++++ API.Tests/Parser/ParserTest.cs | 27 ---------------- API/Controllers/ReadingListController.cs | 32 +++++++++---------- .../Repositories/ReadingListRepository.cs | 2 +- .../Repositories/ISeriesRepository.cs | 2 -- .../book-reader/book-reader.component.html | 2 +- .../book-reader/book-reader.component.scss | 1 + .../book-reader/book-reader.component.ts | 9 ++---- 8 files changed, 31 insertions(+), 53 deletions(-) diff --git a/API.Tests/Parser/ComicParserTests.cs b/API.Tests/Parser/ComicParserTests.cs index 37969d80d..5bd24f714 100644 --- a/API.Tests/Parser/ComicParserTests.cs +++ b/API.Tests/Parser/ComicParserTests.cs @@ -163,6 +163,15 @@ namespace API.Tests.Parser FullFilePath = filepath }); + // Fallback test with bad naming + filepath = @"E:\Comics\Comics\Babe\Babe Vol.1 #1-4\Babe 01.cbr"; + expected.Add(filepath, new ParserInfo + { + Series = "Babe", Volumes = "0", Edition = "", + Chapters = "1", Filename = "Babe 01.cbr", Format = MangaFormat.Archive, + FullFilePath = filepath, IsSpecial = false + }); + foreach (var file in expected.Keys) { var expectedInfo = expected[file]; diff --git a/API.Tests/Parser/ParserTest.cs b/API.Tests/Parser/ParserTest.cs index 039beaf91..8fdf0509d 100644 --- a/API.Tests/Parser/ParserTest.cs +++ b/API.Tests/Parser/ParserTest.cs @@ -100,33 +100,6 @@ namespace API.Tests.Parser Assert.Equal(expected, IsEpub(input)); } - // [Theory] - // [InlineData("Tenjou Tenge Omnibus", "Omnibus")] - // [InlineData("Tenjou Tenge {Full Contact Edition}", "Full Contact Edition")] - // [InlineData("Tenjo Tenge {Full Contact Edition} v01 (2011) (Digital) (ASTC).cbz", "Full Contact Edition")] - // [InlineData("Wotakoi - Love is Hard for Otaku Omnibus v01 (2018) (Digital) (danke-Empire)", "Omnibus")] - // [InlineData("To Love Ru v01 Uncensored (Ch.001-007)", "Uncensored")] - // [InlineData("Chobits Omnibus Edition v01 [Dark Horse]", "Omnibus Edition")] - // [InlineData("[dmntsf.net] One Piece - Digital Colored Comics Vol. 20 Ch. 177 - 30 Million vs 81 Million.cbz", "Digital Colored Comics")] - // [InlineData("AKIRA - c003 (v01) [Full Color] [Darkhorse].cbz", "Full Color")] - // public void ParseEditionTest(string input, string expected) - // { - // Assert.Equal(expected, ParseEdition(input)); - // } - - // [Theory] - // [InlineData("Beelzebub Special OneShot - Minna no Kochikame x Beelzebub (2016) [Mangastream].cbz", true)] - // [InlineData("Beelzebub_Omake_June_2012_RHS", true)] - // [InlineData("Beelzebub_Side_Story_02_RHS.zip", false)] - // [InlineData("Darker than Black Shikkoku no Hana Special [Simple Scans].zip", true)] - // [InlineData("Darker than Black Shikkoku no Hana Fanbook Extra [Simple Scans].zip", true)] - // [InlineData("Corpse Party -The Anthology- Sachikos game of love Hysteric Birthday 2U Extra Chapter", true)] - // [InlineData("Ani-Hina Art Collection.cbz", true)] - // public void ParseMangaSpecialTest(string input, bool expected) - // { - // Assert.Equal(expected, ParseMangaSpecial(input) != ""); - // } - [Theory] [InlineData("12-14", 12)] [InlineData("24", 24)] diff --git a/API/Controllers/ReadingListController.cs b/API/Controllers/ReadingListController.cs index 03a8d7c9d..19e4a4b49 100644 --- a/API/Controllers/ReadingListController.cs +++ b/API/Controllers/ReadingListController.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using API.Comparators; @@ -99,16 +100,20 @@ namespace API.Controllers [HttpPost("delete-item")] public async Task DeleteListItem(UpdateReadingListPosition dto) { - var items = (await _unitOfWork.ReadingListRepository.GetReadingListItemsByIdAsync(dto.ReadingListId)).ToList(); - var item = items.Find(r => r.Id == dto.ReadingListItemId); - items.Remove(item); + var readingList = await _unitOfWork.ReadingListRepository.GetReadingListByIdAsync(dto.ReadingListId); + readingList.Items = readingList.Items.Where(r => r.Id != dto.ReadingListItemId).ToList(); - for (var i = 0; i < items.Count; i++) + + var index = 0; + foreach (var readingListItem in readingList.Items) { - items[i].Order = i; + readingListItem.Order = index; + index++; } - if (_unitOfWork.HasChanges() && await _unitOfWork.CommitAsync()) + if (!_unitOfWork.HasChanges()) return Ok(); + + if (await _unitOfWork.CommitAsync()) { return Ok("Updated"); } @@ -138,15 +143,10 @@ namespace API.Controllers itemIdsToRemove.Contains(r.Id)); _unitOfWork.ReadingListRepository.BulkRemove(listItems); - if (_unitOfWork.HasChanges()) - { - await _unitOfWork.CommitAsync(); - return Ok("Updated"); - } - else - { - return Ok("Nothing to remove"); - } + if (!_unitOfWork.HasChanges()) return Ok("Nothing to remove"); + + await _unitOfWork.CommitAsync(); + return Ok("Updated"); } catch { diff --git a/API/Data/Repositories/ReadingListRepository.cs b/API/Data/Repositories/ReadingListRepository.cs index 4f44bc943..fc9199ccb 100644 --- a/API/Data/Repositories/ReadingListRepository.cs +++ b/API/Data/Repositories/ReadingListRepository.cs @@ -53,7 +53,7 @@ namespace API.Data.Repositories { return await _context.ReadingList .Where(r => r.Id == readingListId) - .Include(r => r.Items) + .Include(r => r.Items.OrderBy(item => item.Order)) .SingleOrDefaultAsync(); } diff --git a/API/Interfaces/Repositories/ISeriesRepository.cs b/API/Interfaces/Repositories/ISeriesRepository.cs index 9b04d6d9f..0b3ed8eeb 100644 --- a/API/Interfaces/Repositories/ISeriesRepository.cs +++ b/API/Interfaces/Repositories/ISeriesRepository.cs @@ -42,8 +42,6 @@ namespace API.Interfaces.Repositories /// /// Task AddSeriesModifiers(int userId, List series); - - Task GetSeriesCoverImageAsync(int seriesId); Task> GetInProgress(int userId, int libraryId, UserParams userParams, FilterDto filter); Task> GetRecentlyAdded(int libraryId, int userId, UserParams userParams, FilterDto filter); // NOTE: Probably put this in LibraryRepo diff --git a/UI/Web/src/app/book-reader/book-reader/book-reader.component.html b/UI/Web/src/app/book-reader/book-reader/book-reader.component.html index 19ec43a2b..99bba7fc2 100644 --- a/UI/Web/src/app/book-reader/book-reader/book-reader.component.html +++ b/UI/Web/src/app/book-reader/book-reader/book-reader.component.html @@ -58,7 +58,7 @@
- +
diff --git a/UI/Web/src/app/book-reader/book-reader/book-reader.component.scss b/UI/Web/src/app/book-reader/book-reader/book-reader.component.scss index 0f57b6372..f7c62217e 100644 --- a/UI/Web/src/app/book-reader/book-reader/book-reader.component.scss +++ b/UI/Web/src/app/book-reader/book-reader/book-reader.component.scss @@ -208,6 +208,7 @@ $primary-color: #0062cc; .btn { &.btn-secondary { + color: #6c757d; border-color: transparent; background-color: unset; diff --git a/UI/Web/src/app/book-reader/book-reader/book-reader.component.ts b/UI/Web/src/app/book-reader/book-reader/book-reader.component.ts index 8312c7325..628c0a35d 100644 --- a/UI/Web/src/app/book-reader/book-reader/book-reader.component.ts +++ b/UI/Web/src/app/book-reader/book-reader/book-reader.component.ts @@ -285,6 +285,8 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { fromEvent(window, 'scroll') .pipe(debounceTime(200), takeUntil(this.onDestroy)).subscribe((event) => { if (this.isLoading) return; + + // Highlight the current chapter we are on if (Object.keys(this.pageAnchors).length !== 0) { // get the height of the document so we can capture markers that are halfway on the document viewport const verticalOffset = this.scrollService.scrollPosition + (document.body.offsetHeight / 2); @@ -292,11 +294,6 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { const alreadyReached = Object.values(this.pageAnchors).filter((i: number) => i <= verticalOffset); if (alreadyReached.length > 0) { this.currentPageAnchor = Object.keys(this.pageAnchors)[alreadyReached.length - 1]; - - if (!this.incognitoMode) { - this.readerService.saveProgress(this.seriesId, this.volumeId, this.chapterId, this.pageNum, this.lastSeenScrollPartPath).pipe(take(1)).subscribe(() => {/* No operation */}); - } - return; } else { this.currentPageAnchor = ''; } @@ -322,7 +319,7 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { return 0; }); - + if (intersectingEntries.length > 0) { let path = this.getXPathTo(intersectingEntries[0]); if (path === '') { return; }