mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-11-03 19:17:05 -05:00 
			
		
		
		
	* Tweaked a Migration to log correctly only if something is going to be done. * Refactored Reading List Controller code into a dedicated service and cleaned up some methods that aren't needed anymore. * Fixed a bug where adding a new item to a reading list wasn't adding it at the end. * Fixed an issue where collection page would re-render the same covers on multiple items. * Fixed a missing margin-top which made the page extras drawer not render correctly and hence unclosable on small screens. * Added some timeout on manage users screen to give data time to flush. Added a dedicated token log for account flows, in case url encoding plays a part (but from testing it doesn't). * Reverted back to building for ES6 instead of es2020 for old Safari 12.5.5 browsers (10MB difference in build size). * Cleaned up the logic in removing series not found during scan loop. * Tweaked the timings for Library Watcher to 1 min and reprocess queue every 30 seconds.
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.Linq;
 | 
						|
using System.Threading.Tasks;
 | 
						|
using API.Services.Tasks;
 | 
						|
 | 
						|
namespace API.Data;
 | 
						|
 | 
						|
/// <summary>
 | 
						|
/// In v0.5.3, we removed Light and E-Ink themes. This migration will remove the themes from the DB and default anyone on
 | 
						|
/// null, E-Ink, or Light to Dark.
 | 
						|
/// </summary>
 | 
						|
public static class MigrateRemoveExtraThemes
 | 
						|
{
 | 
						|
    public static async Task Migrate(IUnitOfWork unitOfWork, IThemeService themeService)
 | 
						|
    {
 | 
						|
        var themes = (await unitOfWork.SiteThemeRepository.GetThemes()).ToList();
 | 
						|
 | 
						|
        if (themes.FirstOrDefault(t => t.Name.Equals("Light")) == null)
 | 
						|
        {
 | 
						|
            return;
 | 
						|
        }
 | 
						|
 | 
						|
        Console.WriteLine("Removing Dark and E-Ink themes");
 | 
						|
 | 
						|
        var darkTheme = themes.Single(t => t.Name.Equals("Dark"));
 | 
						|
        var lightTheme = themes.Single(t => t.Name.Equals("Light"));
 | 
						|
        var eInkTheme = themes.Single(t => t.Name.Equals("E-Ink"));
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        // Update default theme if it's not Dark or a custom theme
 | 
						|
        await themeService.UpdateDefault(darkTheme.Id);
 | 
						|
 | 
						|
        // Update all users to Dark theme if they are on Light/E-Ink
 | 
						|
        foreach (var pref in await unitOfWork.UserRepository.GetAllPreferencesByThemeAsync(lightTheme.Id))
 | 
						|
        {
 | 
						|
            pref.Theme = darkTheme;
 | 
						|
        }
 | 
						|
        foreach (var pref in await unitOfWork.UserRepository.GetAllPreferencesByThemeAsync(eInkTheme.Id))
 | 
						|
        {
 | 
						|
            pref.Theme = darkTheme;
 | 
						|
        }
 | 
						|
 | 
						|
        // Remove Light/E-Ink themes
 | 
						|
        foreach (var siteTheme in themes.Where(t => t.Name.Equals("Light") || t.Name.Equals("E-Ink")))
 | 
						|
        {
 | 
						|
            unitOfWork.SiteThemeRepository.Remove(siteTheme);
 | 
						|
        }
 | 
						|
        // Commit and call it a day
 | 
						|
        await unitOfWork.CommitAsync();
 | 
						|
 | 
						|
        Console.WriteLine("Completed removing Dark and E-Ink themes");
 | 
						|
    }
 | 
						|
 | 
						|
}
 |