mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-01 12:44:44 -04:00
Changed how covers are merged together. Now a cover image will always be generated for reading list and collections. Fixed reading list page being a bit laggy due to a missing trackby function. Reading list page will now show the cover image always. Collection detail page will only hide the image if there is no summary on the collection.
91 lines
3.7 KiB
C#
91 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using API.DTOs.Settings;
|
|
using API.Entities;
|
|
using API.Entities.Enums;
|
|
using AutoMapper;
|
|
|
|
namespace API.Helpers.Converters;
|
|
|
|
public class ServerSettingConverter : ITypeConverter<IEnumerable<ServerSetting>, ServerSettingDto>
|
|
{
|
|
public ServerSettingDto Convert(IEnumerable<ServerSetting> source, ServerSettingDto destination, ResolutionContext context)
|
|
{
|
|
destination ??= new ServerSettingDto();
|
|
foreach (var row in source)
|
|
{
|
|
switch (row.Key)
|
|
{
|
|
case ServerSettingKey.CacheDirectory:
|
|
destination.CacheDirectory = row.Value;
|
|
break;
|
|
case ServerSettingKey.TaskScan:
|
|
destination.TaskScan = row.Value;
|
|
break;
|
|
case ServerSettingKey.LoggingLevel:
|
|
destination.LoggingLevel = row.Value;
|
|
break;
|
|
case ServerSettingKey.TaskBackup:
|
|
destination.TaskBackup = row.Value;
|
|
break;
|
|
case ServerSettingKey.Port:
|
|
destination.Port = int.Parse(row.Value);
|
|
break;
|
|
case ServerSettingKey.IpAddresses:
|
|
destination.IpAddresses = row.Value;
|
|
break;
|
|
case ServerSettingKey.AllowStatCollection:
|
|
destination.AllowStatCollection = bool.Parse(row.Value);
|
|
break;
|
|
case ServerSettingKey.EnableOpds:
|
|
destination.EnableOpds = bool.Parse(row.Value);
|
|
break;
|
|
case ServerSettingKey.BaseUrl:
|
|
destination.BaseUrl = row.Value;
|
|
break;
|
|
case ServerSettingKey.BookmarkDirectory:
|
|
destination.BookmarksDirectory = row.Value;
|
|
break;
|
|
case ServerSettingKey.EmailServiceUrl:
|
|
destination.EmailServiceUrl = row.Value;
|
|
break;
|
|
case ServerSettingKey.InstallVersion:
|
|
destination.InstallVersion = row.Value;
|
|
break;
|
|
case ServerSettingKey.EncodeMediaAs:
|
|
destination.EncodeMediaAs = Enum.Parse<EncodeFormat>(row.Value);
|
|
break;
|
|
case ServerSettingKey.TotalBackups:
|
|
destination.TotalBackups = int.Parse(row.Value);
|
|
break;
|
|
case ServerSettingKey.InstallId:
|
|
destination.InstallId = row.Value;
|
|
break;
|
|
case ServerSettingKey.EnableFolderWatching:
|
|
destination.EnableFolderWatching = bool.Parse(row.Value);
|
|
break;
|
|
case ServerSettingKey.TotalLogs:
|
|
destination.TotalLogs = int.Parse(row.Value);
|
|
break;
|
|
case ServerSettingKey.HostName:
|
|
destination.HostName = row.Value;
|
|
break;
|
|
case ServerSettingKey.CacheSize:
|
|
destination.CacheSize = long.Parse(row.Value);
|
|
break;
|
|
case ServerSettingKey.OnDeckProgressDays:
|
|
destination.OnDeckProgressDays = int.Parse(row.Value);
|
|
break;
|
|
case ServerSettingKey.OnDeckUpdateDays:
|
|
destination.OnDeckUpdateDays = int.Parse(row.Value);
|
|
break;
|
|
case ServerSettingKey.CoverImageSize:
|
|
destination.CoverImageSize = Enum.Parse<CoverImageSize>(row.Value);
|
|
break;
|
|
}
|
|
}
|
|
|
|
return destination;
|
|
}
|
|
}
|