Remove Light and E-Ink theme (#1263)

* Refactored code to show action bar instead of drawer in immersive mode

* Card grid

* adding margin for pagination gap

* Fixed a rare routing case that wouldn't redirect

* Fixed a bug where series detail would show blank filtering

* Fixing image scaling and library card spacing

* Refactored some methods to be static

* Adding card grid to series detail

* Fixed a bug with webtoon going to non-webtoon mode, resulting in black screen.

* Ensure emails are trimmed when trying to invite.

* Don't show More In if there is only 1 item in there on library recommended tab

* Fixed some bugs around locking metadata fields where the correct param wasn't being sent to backend.

* Added some UI error messaging when the email doesn't match the confirm-email (or rather any email in the system).

* Fixed some pages where actions weren't working (library detail) and removed some actionable buttons where they didn't make sense

* Refactored the series detail to use Robbie's new grid system.

* some styling fixes

* Styling fixes

- Removing select border gap
- fixing switches on lite theme
- fixing search result text-light

* better css var naming

* changing search lite text color override

* fixing as per feedback

* Removing boolean from being visible in bookreader

* Fixed some bugs in bulk operations not being visible on light/eink screens. Added --bulk-selection-highlight-text-color and --bulk-selection-text-color.

* Wrote basic code to remove other themes. Need a migration instead.

* Added a migration to remove light/e-ink themes and migrate users over to Dark theme by default.

* Fixed unit tests

Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
Joseph Milazzo 2022-05-19 07:14:18 -05:00 committed by GitHub
parent 876e19177e
commit f2b1cd55f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 67 additions and 20 deletions

View file

@ -0,0 +1,56 @@
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)
{
Console.WriteLine("Removing Dark and E-Ink themes");
var themes = (await unitOfWork.SiteThemeRepository.GetThemes()).ToList();
if (themes.FirstOrDefault(t => t.Name.Equals("Light")) == null)
{
Console.WriteLine("Done. Nothing to do");
return;
}
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");
}
}

View file

@ -33,23 +33,7 @@ namespace API.Data
Provider = ThemeProvider.System,
FileName = "dark.scss",
IsDefault = true,
},
new()
{
Name = "Light",
NormalizedName = Parser.Parser.Normalize("Light"),
Provider = ThemeProvider.System,
FileName = "light.scss",
IsDefault = false,
},
new()
{
Name = "E-Ink",
NormalizedName = Parser.Parser.Normalize("E-Ink"),
Provider = ThemeProvider.System,
FileName = "e-ink.scss",
IsDefault = false,
},
}
}.ToArray());
public static async Task SeedRoles(RoleManager<AppRole> roleManager)

View file

@ -147,6 +147,7 @@ namespace API
// Apply all migrations on startup
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
var userManager = serviceProvider.GetRequiredService<UserManager<AppUser>>();
var themeService = serviceProvider.GetRequiredService<IThemeService>();
await MigrateBookmarks.Migrate(directoryService, unitOfWork,
logger, cacheService);
@ -154,6 +155,8 @@ namespace API
// Only run this if we are upgrading
await MigrateChangePasswordRoles.Migrate(unitOfWork, userManager);
await MigrateRemoveExtraThemes.Migrate(unitOfWork, themeService);
// Update the version in the DB after all migrations are run
var installVersion = await unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.InstallVersion);
installVersion.Value = BuildInfo.Version.ToString();