Manga Reader Work (#1729)

* Instead of augmenting prefetcher to move across chapter bounds, let's try to instead just load 5 images (which the browser will cache) from next/prev so when it loads, it's much faster.

* Trialing loading next/prev chapters 5 pages to have better next page loading experience.

* Tweaked GetChapterInfo API to actually apply conditional includeDimensions parameter.

* added a basic language file for upcoming work

* Moved the bottom menu up a bit for iOS devices with handlebars.

* Fixed fit to width on phones still having a horizontal scrollbar

* Fixed a bug where there is extra space under the image when fit to width and on a phone due to pagination going to far.

* Changed which variable we use for right pagination calculation

* Fixing fit to height

- Fixing height calc to account for horizontal scroll bar height.

* Added a comment for the height scrollbar fix

* Adding screenfull package

# Added:
- Added screenfull package to handle cross-platform browser fullscreen code

# Removed:
- Removed custom fullscreen code

* Fixed a bug where switching from webtoon reader to other layout modes wouldn't render anything. Webtoon continuous scroll down is now broken.

* Fixed it back to how it was and all is good. Need to call detectChanges explicitly.

* Removed an additional undeeded save progress call on loadPage

* Laid out the test case to move the page snapping to the backend with full unit tests. Current code is broken just like UI layer.

* Refactored the snap points into the backend and ensure that it works correctly.

* Fixed a broken unit test

* Filter out spammy hubs/messages calls in the logs

* Swallow all noisy messages that are from RequestLoggingMiddleware when the log level is on Information or above.

* Added a common loading component to the app. Have yet to refactor all screens to use this.

* Bump json5 from 2.2.0 to 2.2.3 in /UI/Web

Bumps [json5](https://github.com/json5/json5) from 2.2.0 to 2.2.3.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v2.2.0...v2.2.3)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Alrigned all the loading messages and styles throughout the app

* Webtoon reader will use max width of all images to ensure images align well.

* On Original scaling mode, users can use the keyboard to scroll around the images without pagination kicking off.

* Removed console logs

* Fixed a public vs private issue

* Fixed an issue around some cached files getting locked due to NetVips holding them during file size calculations.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Joe Milazzo 2023-01-07 09:14:22 -06:00 committed by GitHub
parent 22442d745c
commit 2464a30bc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 367 additions and 390 deletions

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.IO.Abstractions.TestingHelpers;
using System.Linq;
@ -6,6 +7,7 @@ using System.Threading.Tasks;
using API.Data;
using API.Data.Repositories;
using API.DTOs;
using API.DTOs.Reader;
using API.Entities;
using API.Entities.Enums;
using API.Helpers;
@ -18,11 +20,13 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using NSubstitute;
using Xunit;
using Xunit.Abstractions;
namespace API.Tests.Services;
public class ReaderServiceTests
{
private readonly ITestOutputHelper _testOutputHelper;
private readonly IUnitOfWork _unitOfWork;
@ -33,8 +37,9 @@ public class ReaderServiceTests
private const string BackupDirectory = "C:/kavita/config/backups/";
private const string DataDirectory = "C:/data/";
public ReaderServiceTests()
public ReaderServiceTests(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
var contextOptions = new DbContextOptionsBuilder().UseSqlite(CreateInMemoryDatabase()).Options;
_context = new DataContext(contextOptions);
@ -1294,8 +1299,6 @@ public class ReaderServiceTests
// This is first chapter of first volume
prevChapter = await readerService.GetPrevChapterIdAsync(1, 2,4, 1);
Assert.Equal(-1, prevChapter);
//chapterInfoDto = await _unitOfWork.ChapterRepository.GetChapterInfoDtoAsync(prevChapter);
}
[Fact]
@ -2401,7 +2404,6 @@ public class ReaderServiceTests
[Fact]
public void FormatChapterName_Manga_Chapter()
{
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
var actual = ReaderService.FormatChapterName(LibraryType.Manga, false, false);
Assert.Equal("Chapter", actual);
}
@ -2409,7 +2411,6 @@ public class ReaderServiceTests
[Fact]
public void FormatChapterName_Book_Chapter_WithTitle()
{
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
var actual = ReaderService.FormatChapterName(LibraryType.Book, false, false);
Assert.Equal("Book", actual);
}
@ -2417,7 +2418,6 @@ public class ReaderServiceTests
[Fact]
public void FormatChapterName_Comic()
{
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
var actual = ReaderService.FormatChapterName(LibraryType.Comic, false, false);
Assert.Equal("Issue", actual);
}
@ -2425,7 +2425,6 @@ public class ReaderServiceTests
[Fact]
public void FormatChapterName_Comic_WithHash()
{
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
var actual = ReaderService.FormatChapterName(LibraryType.Comic, true, true);
Assert.Equal("Issue #", actual);
}
@ -2559,4 +2558,46 @@ public class ReaderServiceTests
#endregion
#region GetPairs
[Theory]
[InlineData("No Wides", new [] {false, false, false}, new [] {"0,0", "1,1", "2,1"})]
[InlineData("Test_odd_spread_1.zip", new [] {false, false, false, false, false, true},
new [] {"0,0", "1,1", "2,1", "3,3", "4,3", "5,5"})]
[InlineData("Test_odd_spread_2.zip", new [] {false, false, false, false, false, true, false, false},
new [] {"0,0", "1,1", "2,1", "3,3", "4,3", "5,5", "6,6", "7,6"})]
[InlineData("Test_even_spread_1.zip", new [] {false, false, false, false, false, false, true},
new [] {"0,0", "1,1", "2,1", "3,3", "4,3", "5,5", "6,6"})]
[InlineData("Test_even_spread_2.zip", new [] {false, false, false, false, false, false, true, false, false},
new [] {"0,0", "1,1", "2,1", "3,3", "4,3", "5,5", "6,6", "7,7", "8,7"})]
[InlineData("Edge_cases_SP01.zip", new [] {true, false, false, false},
new [] {"0,0", "1,1", "2,1", "3,3"})]
[InlineData("Edge_cases_SP02.zip", new [] {false, true, false, false, false},
new [] {"0,0", "1,1", "2,2", "3,2", "4,4"})]
[InlineData("Edge_cases_SP03.zip", new [] {false, false, false, false, false, true, true, false, false, false},
new [] {"0,0", "1,1", "2,1", "3,3", "4,3", "5,5", "6,6", "7,7", "8,7", "9,9"})]
[InlineData("Edge_cases_SP04.zip", new [] {false, false, false, false, false, true, false, true, false, false},
new [] {"0,0", "1,1", "2,1", "3,3", "4,3", "5,5", "6,6", "7,7", "8,8", "9,8"})]
[InlineData("Edge_cases_SP05.zip", new [] {false, false, false, false, false, true, false, false, true, false},
new [] {"0,0", "1,1", "2,1", "3,3", "4,3", "5,5", "6,6", "7,6", "8,8", "9,9"})]
public void GetPairs_ShouldReturnPairsForNoWideImages(string caseName, IList<bool> wides, IList<string> expectedPairs)
{
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
var files = wides.Select((b, i) => new FileDimensionDto() {PageNumber = i, Height = 1, Width = 1, FileName = string.Empty, IsWide = b}).ToList();
var pairs = readerService.GetPairs(files);
var expectedDict = new Dictionary<int, int>();
foreach (var pair in expectedPairs)
{
var token = pair.Split(',');
expectedDict.Add(int.Parse(token[0]), int.Parse(token[1]));
}
_testOutputHelper.WriteLine("Case: {0}", caseName);
_testOutputHelper.WriteLine("Expected: {0}", string.Join(", ", expectedDict.Select(kvp => $"{kvp.Key}->{kvp.Value}")));
_testOutputHelper.WriteLine("Actual: {0}", string.Join(", ", pairs.Select(kvp => $"{kvp.Key}->{kvp.Value}")));
Assert.Equal(expectedDict, pairs);
}
#endregion
}