Misc Bugs (#510)

* Don't show bookmark context actionable for books

* Fixed an issue where when adding a collection tag, the logic wouldn't assume the tag already existed in DB and would reset it.

* After editing a series on library page, ensure we refresh collection tags.

* Reload recently added section after changing a series

* Moved all Stat logger events to Debug

* Refactored scroll logic into a single service to keep the code consistent.
This commit is contained in:
Joseph Milazzo 2021-08-19 06:50:14 -07:00 committed by GitHub
parent 914c6f9349
commit 786fa146fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 92 additions and 52 deletions

View file

@ -116,6 +116,8 @@ namespace API.Controllers
_unitOfWork.CollectionTagRepository.Update(tag);
}
tag.CoverImageLocked = updateSeriesForTagDto.Tag.CoverImageLocked;
if (!updateSeriesForTagDto.Tag.CoverImageLocked)
{
tag.CoverImageLocked = false;

View file

@ -242,6 +242,7 @@ namespace API.Controllers
{
var seriesId = updateSeriesMetadataDto.SeriesMetadata.SeriesId;
var series = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(seriesId);
var allTags = (await _unitOfWork.CollectionTagRepository.GetAllTagsAsync()).ToList();
if (series.Metadata == null)
{
series.Metadata = DbFactory.SeriesMetadata(updateSeriesMetadataDto.Tags
@ -266,13 +267,13 @@ namespace API.Controllers
// At this point, all tags that aren't in dto have been removed.
foreach (var tag in updateSeriesMetadataDto.Tags)
{
var existingTag = series.Metadata.CollectionTags.SingleOrDefault(t => t.Title == tag.Title);
var existingTag = allTags.SingleOrDefault(t => t.Title == tag.Title);
if (existingTag != null)
{
// Update existingTag
existingTag.Promoted = tag.Promoted;
existingTag.Title = tag.Title;
existingTag.NormalizedTitle = Parser.Parser.Normalize(tag.Title).ToUpper();
if (!series.Metadata.CollectionTags.Any(t => t.Title == tag.Title))
{
newTags.Add(existingTag);
}
}
else
{

View file

@ -45,6 +45,14 @@ namespace API.Data
return await _context.SaveChangesAsync();
}
public async Task<IEnumerable<CollectionTag>> GetAllTagsAsync()
{
return await _context.CollectionTag
.Select(c => c)
.OrderBy(c => c.NormalizedTitle)
.ToListAsync();
}
public async Task<IEnumerable<CollectionTagDto>> GetAllTagDtosAsync()
{
return await _context.CollectionTag

View file

@ -16,5 +16,6 @@ namespace API.Interfaces
Task<CollectionTag> GetFullTagAsync(int tagId);
void Update(CollectionTag tag);
Task<int> RemoveTagsWithoutSeries();
Task<IEnumerable<CollectionTag>> GetAllTagsAsync();
}
}

View file

@ -41,7 +41,7 @@ namespace API.Services.Tasks
public async Task PathData(ClientInfoDto clientInfoDto)
{
_logger.LogInformation("Pathing client data to the file");
_logger.LogDebug("Pathing client data to the file");
var statisticsDto = await GetData();
@ -52,12 +52,12 @@ namespace API.Services.Tasks
public async Task CollectRelevantData()
{
_logger.LogInformation("Collecting data from the server and database");
_logger.LogDebug("Collecting data from the server and database");
_logger.LogInformation("Collecting usage info");
_logger.LogDebug("Collecting usage info");
var usageInfo = await GetUsageInfo();
_logger.LogInformation("Collecting server info");
_logger.LogDebug("Collecting server info");
var serverInfo = GetServerInfo();
await PathData(serverInfo, usageInfo);
@ -67,14 +67,14 @@ namespace API.Services.Tasks
{
try
{
_logger.LogInformation("Finalizing Stats collection flow");
_logger.LogDebug("Finalizing Stats collection flow");
var data = await GetExistingData<UsageStatisticsDto>();
_logger.LogInformation("Sending data to the Stats server");
_logger.LogDebug("Sending data to the Stats server");
await _client.SendDataToStatsServer(data);
_logger.LogInformation("Deleting the file from disk");
_logger.LogDebug("Deleting the file from disk");
if (FileExists) File.Delete(FinalPath);
}
catch (Exception ex)
@ -92,7 +92,7 @@ namespace API.Services.Tasks
private async Task PathData(ServerInfoDto serverInfoDto, UsageInfoDto usageInfoDto)
{
_logger.LogInformation("Pathing server and usage info to the file");
_logger.LogDebug("Pathing server and usage info to the file");
var data = await GetData();
@ -169,19 +169,19 @@ namespace API.Services.Tasks
private async Task SaveFile(UsageStatisticsDto statisticsDto)
{
_logger.LogInformation("Saving file");
_logger.LogDebug("Saving file");
var finalDirectory = FinalPath.Replace(TempFileName, string.Empty);
if (!Directory.Exists(finalDirectory))
{
_logger.LogInformation("Creating tmp directory");
_logger.LogDebug("Creating tmp directory");
Directory.CreateDirectory(finalDirectory);
}
_logger.LogInformation("Serializing data to write");
_logger.LogDebug("Serializing data to write");
var dataJson = JsonSerializer.Serialize(statisticsDto);
_logger.LogInformation("Writing file to the disk");
_logger.LogDebug("Writing file to the disk");
await File.WriteAllTextAsync(FinalPath, dataJson);
}
}