Change Detection: On Push aka UI Smoothness (#1369)
* Updated Series Info Cards to use OnPush and hooked in progress events when we do a mark as read/unread on entities. These events update progress bars but also will now trigger a re-calculation on Read Time Left. * Removed Library Card Component * Refactored manga reader title and subtitle calculation to the backend. * Coverted card actionables to onPush * Series Card on push cleanup * Updated edit collection tags for on push * Update cover image chooser for on push * Cleaned up carsouel reel * Updated cover image to allow for uploading gif and webp files * Bulk add to collection on push * Updated bulk operation to use on push. Updated bulk operation to have mark as unread and read buttons explicitly. Updated so add to collection is visible and delete. Fixed a bug where manage library component wasn't invoking the trackBy function * Updating entity title for on push * Removed file info component * Updated Mange Library for on push * Entity info cards on push * List item on push * Updated icon and title for on push and fixed some missing change detection on series detail * Restricted the typeahead interface to simplify the design * Edit Series Relation now shows a value in the dropdown for Parent relationships and disables the field. * Updated edit series relation to focus on new typeahead when adding a new relationship * Added some documentation and when Scanning a library, don't allow the user to enqueue the same job multiple times. * Applied the No-enqueue if already enqueued logic to other tasks * Library detail on push * Updated events widget to onpush * Card detail drawer on push. Card detail cover chooser now will show all chapter's covers for selection in cover chooser. * Chapter metadata detail on push * Removed Card Detail modal * All collections on push * Removed some comments * Updated bulk selection to use an observable rather than function calls so new on push strategy works * collection detail now uses on push and scroller is placed on correct element * Updated library recommended to on push. Ensure that when mark as read occurs, the appropriate streams are refreshed. * Updated library detail to on push * Update metadata fiter to onpush. Bugs found and reported to Project * person badge on push * Read more on push * Updated tag badge to on push * User login on push * When initing side nav, don't call an authenticated api until we are sure a user is logged in * Updated splash container to on push * Dashboard on push * Side nav slight refactor around some api calls * Cleaned up series card on push to use same cdRef naming convention * Updated Static Files to use caching * Added width and height to logo image * shortcuts modal on push * reading lists on push * Reading list detail on push * draggable ordered list on push * Refactored reading-list-detail to use a new item which drastically reduces renders on operations * series format on push * circular loader on push * Badge Expander on push * update notification modal on push * drawer on push * Edit Series Modal on push * reset password on push * review series modal on push * series metadata detail on push * theme manager on push * confirm reset password on push * register on push * confirm migration email on push * confirm email on push * add email to account migration on push * user preferences on push. Made global settings default open * edit series relation on push * Fixed an edge case bug for next chapter where if the current volume had a single chapter of 1 and the next volume had a chapter number of 0, it would say there are no more chapters. * Updated infinite scroller with on push support * Moved some animations over to typeahead, not integrated yet. * Manga reader is now on push * Reader settings on push * refactored how we close the book * Updated table of contents for on push * Updated book reader for on push. Fixed a bug where table of contents wasn't showing current page anchor due to a scroll calulation bug * Small code tweak * Icon and title on push * nav header on push * grouped typeahead on push * typeahead on push and added a new trackby identity function to allow even faster rendering of big lists * pdf reader on push * code cleanup
This commit is contained in:
parent
f5be0fac58
commit
4e49aa47ce
126 changed files with 1658 additions and 1674 deletions
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.Linq;
|
||||
|
|
@ -16,7 +15,6 @@ using API.Tests.Helpers;
|
|||
using AutoMapper;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
|
@ -28,7 +26,6 @@ public class ReaderServiceTests
|
|||
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
private readonly DbConnection _connection;
|
||||
private readonly DataContext _context;
|
||||
|
||||
private const string CacheDirectory = "C:/kavita/config/cache/";
|
||||
|
|
@ -39,7 +36,6 @@ public class ReaderServiceTests
|
|||
public ReaderServiceTests()
|
||||
{
|
||||
var contextOptions = new DbContextOptionsBuilder().UseSqlite(CreateInMemoryDatabase()).Options;
|
||||
_connection = RelationalOptionsExtension.Extract(contextOptions).Connection;
|
||||
|
||||
_context = new DataContext(contextOptions);
|
||||
Task.Run(SeedDb).GetAwaiter().GetResult();
|
||||
|
|
@ -83,7 +79,7 @@ public class ReaderServiceTests
|
|||
return await _context.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
private async Task ResetDB()
|
||||
private async Task ResetDb()
|
||||
{
|
||||
_context.Series.RemoveRange(_context.Series.ToList());
|
||||
|
||||
|
|
@ -122,7 +118,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task CapPageToChapterTest()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -161,7 +157,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task SaveReadingProgress_ShouldCreateNewEntity()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -210,7 +206,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task SaveReadingProgress_ShouldUpdateExisting()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -276,7 +272,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task MarkChaptersAsReadTest()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -314,7 +310,7 @@ public class ReaderServiceTests
|
|||
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
||||
|
||||
var volumes = await _unitOfWork.VolumeRepository.GetVolumes(1);
|
||||
readerService.MarkChaptersAsRead(await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress), 1, volumes.First().Chapters);
|
||||
await readerService.MarkChaptersAsRead(await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress), 1, volumes.First().Chapters);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
Assert.Equal(2, (await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress)).Progresses.Count);
|
||||
|
|
@ -326,7 +322,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task MarkChapterAsUnreadTest()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -364,12 +360,12 @@ public class ReaderServiceTests
|
|||
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
||||
|
||||
var volumes = (await _unitOfWork.VolumeRepository.GetVolumes(1)).ToList();
|
||||
readerService.MarkChaptersAsRead(await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress), 1, volumes.First().Chapters);
|
||||
await readerService.MarkChaptersAsRead(await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress), 1, volumes.First().Chapters);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
Assert.Equal(2, (await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress)).Progresses.Count);
|
||||
|
||||
readerService.MarkChaptersAsUnread(await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress), 1, volumes.First().Chapters);
|
||||
await readerService.MarkChaptersAsUnread(await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress), 1, volumes.First().Chapters);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var progresses = (await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress)).Progresses;
|
||||
|
|
@ -385,7 +381,7 @@ public class ReaderServiceTests
|
|||
public async Task GetNextChapterIdAsync_ShouldGetNextVolume()
|
||||
{
|
||||
// V1 -> V2
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -431,7 +427,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetNextChapterIdAsync_ShouldRollIntoNextVolume()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -478,7 +474,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetNextChapterIdAsync_ShouldRollIntoChaptersFromVolume()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -518,10 +514,55 @@ public class ReaderServiceTests
|
|||
Assert.Equal("1", actualChapter.Range);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetNextChapterIdAsync_ShouldRollIntoNextChapterWhenVolumesAreOnlyOneChapterAndNextChapterIs0()
|
||||
{
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library() {
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
},
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("66", false, new List<MangaFile>()),
|
||||
EntityFactory.CreateChapter("67", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("0", false, new List<MangaFile>()),
|
||||
}),
|
||||
}
|
||||
});
|
||||
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
UserName = "majora2007"
|
||||
});
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
||||
|
||||
var nextChapter = await readerService.GetNextChapterIdAsync(1, 2, 3, 1);
|
||||
Assert.NotEqual(-1, nextChapter);
|
||||
var actualChapter = await _unitOfWork.ChapterRepository.GetChapterAsync(nextChapter);
|
||||
Assert.Equal("0", actualChapter.Range);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetNextChapterIdAsync_ShouldFindNoNextChapterFromSpecial()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -562,7 +603,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetNextChapterIdAsync_ShouldFindNoNextChapterFromVolume()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -598,7 +639,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetNextChapterIdAsync_ShouldFindNoNextChapterFromLastChapter_NoSpecials()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -639,7 +680,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetNextChapterIdAsync_ShouldMoveFromVolumeToSpecial_NoLooseLeafChapters()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -682,7 +723,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetNextChapterIdAsync_ShouldMoveFromLooseLeafChapterToSpecial()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -721,7 +762,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetNextChapterIdAsync_ShouldFindNoNextChapterFromSpecial_WithVolumeAndLooseLeafChapters()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -763,7 +804,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetNextChapterIdAsync_ShouldMoveFromSpecialToSpecial()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -811,7 +852,7 @@ public class ReaderServiceTests
|
|||
public async Task GetPrevChapterIdAsync_ShouldGetPrevVolume()
|
||||
{
|
||||
// V1 -> V2
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -857,7 +898,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetPrevChapterIdAsync_ShouldRollIntoPrevVolume()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -904,7 +945,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetPrevChapterIdAsync_ShouldMoveFromSpecialToVolume()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -947,7 +988,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetPrevChapterIdAsync_ShouldFindNoPrevChapterFromVolume()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -983,7 +1024,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetPrevChapterIdAsync_ShouldFindNoPrevChapterFromVolumeWithZeroChapter()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -1018,7 +1059,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetPrevChapterIdAsync_ShouldFindNoPrevChapterFromVolumeWithZeroChapterAndHasNormalChapters()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -1058,7 +1099,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetPrevChapterIdAsync_ShouldFindNoPrevChapterFromVolumeWithZeroChapterAndHasNormalChapters2()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -1112,7 +1153,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetPrevChapterIdAsync_ShouldFindNoPrevChapterFromChapter()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -1148,7 +1189,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetPrevChapterIdAsync_ShouldMoveFromSpecialToSpecial()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -1191,7 +1232,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task GetPrevChapterIdAsync_ShouldMoveFromChapterToVolume()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -1902,7 +1943,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task MarkChaptersUntilAsRead_ShouldMarkAsReadAnythingUntil()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
|
|
@ -1979,7 +2020,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task MarkSeriesAsReadTest()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -2044,7 +2085,7 @@ public class ReaderServiceTests
|
|||
[Fact]
|
||||
public async Task MarkSeriesAsUnreadTest()
|
||||
{
|
||||
await ResetDB();
|
||||
await ResetDb();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
{
|
||||
|
|
@ -2082,7 +2123,7 @@ public class ReaderServiceTests
|
|||
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
||||
|
||||
var volumes = (await _unitOfWork.VolumeRepository.GetVolumes(1)).ToList();
|
||||
readerService.MarkChaptersAsRead(await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress), 1, volumes.First().Chapters);
|
||||
await readerService.MarkChaptersAsRead(await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress), 1, volumes.First().Chapters);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
Assert.Equal(2, (await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Progress)).Progresses.Count);
|
||||
|
|
@ -2096,4 +2137,40 @@ public class ReaderServiceTests
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region FormatChapterName
|
||||
|
||||
[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);
|
||||
}
|
||||
|
||||
[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);
|
||||
}
|
||||
|
||||
[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);
|
||||
}
|
||||
|
||||
[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);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue