Filtering Bugs (#447)

# Fixed
- Fixed: Fixed an issue with filtering, after applying a filter, the cards on screen did not update with the correct information
- Fixed: Pagination is now slighlty smaller (only 8 pages) as on mobile, it was cutting off screen.

# Changed
- Changed: During library scan and series updates, Series names for Epubs will now trim excess white space
===============================================

* Fixed issue where some formats could get returned with another format filter.

* Filtering was not properly flushing DOM on filter change, updated trackbyidentity to account for filter

* One more fix for the filtering bug

* Made pagination UI slightly smaller to better fit on mobile phones. Trim() series names for Epub files and Trim() on series update for appropriate fields.

* Removed a no longer needed animation.
This commit is contained in:
Joseph Milazzo 2021-07-28 14:11:49 -05:00 committed by GitHub
parent 55dd9e7f1e
commit 58856c0d70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 25 deletions

View file

@ -1,10 +1,12 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using API.Comparators;
using API.DTOs;
using API.DTOs.Filtering;
using API.Entities;
using API.Entities.Enums;
using API.Extensions;
using API.Helpers;
using API.Interfaces;
@ -78,8 +80,9 @@ namespace API.Data
public async Task<PagedList<SeriesDto>> GetSeriesDtoForLibraryIdAsync(int libraryId, int userId, UserParams userParams, FilterDto filter)
{
var formats = filter.GetSqlFilter();
var query = _context.Series
.Where(s => s.LibraryId == libraryId && (filter.MangaFormat == null || s.Format == filter.MangaFormat))
.Where(s => s.LibraryId == libraryId && formats.Contains(s.Format))
.OrderBy(s => s.SortName)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
.AsNoTracking();
@ -307,6 +310,8 @@ namespace API.Data
/// <returns></returns>
public async Task<PagedList<SeriesDto>> GetRecentlyAdded(int libraryId, int userId, UserParams userParams, FilterDto filter)
{
var formats = filter.GetSqlFilter();
if (libraryId == 0)
{
var userLibraries = _context.Library
@ -317,7 +322,7 @@ namespace API.Data
.ToList();
var allQuery = _context.Series
.Where(s => userLibraries.Contains(s.LibraryId) && (filter.MangaFormat == null || s.Format == filter.MangaFormat))
.Where(s => userLibraries.Contains(s.LibraryId) && formats.Contains(s.Format))
.AsNoTracking()
.OrderByDescending(s => s.Created)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
@ -327,7 +332,7 @@ namespace API.Data
}
var query = _context.Series
.Where(s => s.LibraryId == libraryId && (filter.MangaFormat == null || s.Format == filter.MangaFormat))
.Where(s => s.LibraryId == libraryId && formats.Contains(s.Format))
.AsNoTracking()
.OrderByDescending(s => s.Created)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
@ -346,9 +351,9 @@ namespace API.Data
/// <returns></returns>
public async Task<PagedList<SeriesDto>> GetInProgress(int userId, int libraryId, UserParams userParams, FilterDto filter)
{
var formats = filter.GetSqlFilter();
var series = _context.Series
.Where(s => filter.MangaFormat == null || s.Format == filter.MangaFormat)
.Where(s => formats.Contains(s.Format))
.Join(_context.AppUserProgresses, s => s.Id, progress => progress.SeriesId, (s, progress) => new
{
Series = s,
@ -367,14 +372,16 @@ namespace API.Data
series = series.Where(s => s.AppUserId == userId
&& s.PagesRead > 0
&& s.PagesRead < s.Series.Pages
&& userLibraries.Contains(s.Series.LibraryId));
&& userLibraries.Contains(s.Series.LibraryId)
&& formats.Contains(s.Series.Format));
}
else
{
series = series.Where(s => s.AppUserId == userId
&& s.PagesRead > 0
&& s.PagesRead < s.Series.Pages
&& s.Series.LibraryId == libraryId);
&& s.Series.LibraryId == libraryId
&& formats.Contains(s.Series.Format));
}
var retSeries = series