Fix implicit profiles being created when opening a reader

- Fix default profiles not being marked as such when creating an account
- Mention that no implicit profiles are created for pdfs
This commit is contained in:
Amelia 2025-06-01 15:21:01 +02:00
parent a67e15bbb3
commit 643c499f16
5 changed files with 20 additions and 14 deletions

View file

@ -154,7 +154,7 @@ public class AccountController : BaseApiController
AddDefaultStreamsToUser(user); AddDefaultStreamsToUser(user);
// Assign default reading profile // Assign default reading profile
AddDefaultReadingProfileToUser(user); await AddDefaultReadingProfileToUser(user);
var token = await _userManager.GenerateEmailConfirmationTokenAsync(user); var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
if (string.IsNullOrEmpty(token)) return BadRequest(await _localizationService.Get("en", "confirm-token-gen")); if (string.IsNullOrEmpty(token)) return BadRequest(await _localizationService.Get("en", "confirm-token-gen"));
@ -673,7 +673,7 @@ public class AccountController : BaseApiController
AddDefaultStreamsToUser(user); AddDefaultStreamsToUser(user);
// Assign default reading profile // Assign default reading profile
AddDefaultReadingProfileToUser(user); await AddDefaultReadingProfileToUser(user);
// Assign Roles // Assign Roles
var roles = dto.Roles; var roles = dto.Roles;
@ -785,17 +785,15 @@ public class AccountController : BaseApiController
} }
} }
private void AddDefaultReadingProfileToUser(AppUser user) private async Task AddDefaultReadingProfileToUser(AppUser user)
{ {
var profile = new AppUserReadingProfileBuilder(user.Id) var profile = new AppUserReadingProfileBuilder(user.Id)
.WithName("Default Profile") .WithName("Default Profile")
.Build(); .Build();
_unitOfWork.AppUserReadingProfileRepository.Attach(profile); _unitOfWork.AppUserReadingProfileRepository.Add(profile);
await _unitOfWork.CommitAsync();
user.UserPreferences.ReadingProfiles.Add(profile); user.UserPreferences.ReadingProfiles.Add(profile);
// TODO: This doesn't save, but I've had to revert it having the full entity or everything would start failing
// in tests because of foreign key constrains. This HAS to be resolved as the code does expect there to always be a
// default profile
user.UserPreferences.DefaultReadingProfileId = profile.Id; user.UserPreferences.DefaultReadingProfileId = profile.Id;
} }

View file

@ -128,6 +128,7 @@ public class ReadingProfileService(IUnitOfWork unitOfWork, ILocalizationService
var newProfile = new AppUserReadingProfileBuilder(user.Id).Build(); var newProfile = new AppUserReadingProfileBuilder(user.Id).Build();
UpdateReaderProfileFields(newProfile, dto); UpdateReaderProfileFields(newProfile, dto);
unitOfWork.AppUserReadingProfileRepository.Add(newProfile); unitOfWork.AppUserReadingProfileRepository.Add(newProfile);
user.UserPreferences.ReadingProfiles.Add(newProfile);
await unitOfWork.CommitAsync(); await unitOfWork.CommitAsync();

View file

@ -10,7 +10,7 @@ import {
Output Output
} from '@angular/core'; } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { take } from 'rxjs'; import {skip, take} from 'rxjs';
import { BookPageLayoutMode } from 'src/app/_models/readers/book-page-layout-mode'; import { BookPageLayoutMode } from 'src/app/_models/readers/book-page-layout-mode';
import { BookTheme } from 'src/app/_models/preferences/book-theme'; import { BookTheme } from 'src/app/_models/preferences/book-theme';
import { ReadingDirection } from 'src/app/_models/preferences/reading-direction'; import { ReadingDirection } from 'src/app/_models/preferences/reading-direction';
@ -210,7 +210,7 @@ export class ReaderSettingsComponent implements OnInit {
this.setupSettings(); this.setupSettings();
this.setTheme(this.readingProfile.bookReaderThemeName || this.themeService.defaultBookTheme); this.setTheme(this.readingProfile.bookReaderThemeName || this.themeService.defaultBookTheme, false);
this.cdRef.markForCheck(); this.cdRef.markForCheck();
// Emit first time so book reader gets the setting // Emit first time so book reader gets the setting
@ -288,6 +288,7 @@ export class ReaderSettingsComponent implements OnInit {
this.settingsForm.valueChanges.pipe( this.settingsForm.valueChanges.pipe(
debounceTime(300), debounceTime(300),
distinctUntilChanged(), distinctUntilChanged(),
skip(1), // Skip the initial creation of the form, we do not want an implicit profile of this snapshot
takeUntilDestroyed(this.destroyRef), takeUntilDestroyed(this.destroyRef),
tap(_ => this.updateImplicit()) tap(_ => this.updateImplicit())
).subscribe(); ).subscribe();
@ -346,12 +347,15 @@ export class ReaderSettingsComponent implements OnInit {
}; };
} }
setTheme(themeName: string) { setTheme(themeName: string, update: boolean = true) {
const theme = this.themes.find(t => t.name === themeName); const theme = this.themes.find(t => t.name === themeName);
this.activeTheme = theme; this.activeTheme = theme;
this.cdRef.markForCheck(); this.cdRef.markForCheck();
this.colorThemeUpdate.emit(theme); this.colorThemeUpdate.emit(theme);
this.updateImplicit();
if (update) {
this.updateImplicit();
}
} }
toggleReadingDirection() { toggleReadingDirection() {

View file

@ -25,6 +25,7 @@ import {
merge, merge,
Observable, Observable,
ReplaySubject, ReplaySubject,
skip,
Subject, Subject,
take, take,
tap tap
@ -616,11 +617,11 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy {
this.init(); this.init();
// TODO: Fix this, it's going off way too often
// Update implicit reading profile while changing settings // Update implicit reading profile while changing settings
this.generalSettingsForm.valueChanges.pipe( this.generalSettingsForm.valueChanges.pipe(
debounceTime(300), debounceTime(300),
distinctUntilChanged(), distinctUntilChanged(),
skip(1), // Skip the initial creation of the form, we do not want an implicit profile of this snapshot
takeUntilDestroyed(this.destroyRef), takeUntilDestroyed(this.destroyRef),
map(_ => this.packReadingProfile()), map(_ => this.packReadingProfile()),
distinctUntilChanged(), distinctUntilChanged(),
@ -821,7 +822,9 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy {
disableDoubleRendererIfScreenTooSmall() { disableDoubleRendererIfScreenTooSmall() {
if (window.innerWidth > window.innerHeight) { if (window.innerWidth > window.innerHeight) {
this.generalSettingsForm.get('layoutMode')?.enable(); if (this.generalSettingsForm.get('layoutMode')?.disabled) {
this.generalSettingsForm.get('layoutMode')?.enable();
}
this.cdRef.markForCheck(); this.cdRef.markForCheck();
return; return;
} }

View file

@ -2803,7 +2803,7 @@
"manage-reading-profiles": { "manage-reading-profiles": {
"description": "Not all your series may be read in the same way, set up distinct reading profiles per library or series to make getting back in your series as seamless as possible.", "description": "Not all your series may be read in the same way, set up distinct reading profiles per library or series to make getting back in your series as seamless as possible.",
"extra-tip": "Assign reading profiles via the action menu on series and libraries, or in bulk. When changing settings in a reader, a hidden profile is created that remembers your choices for that series. This profile is removed when you assign or update one of your own reading profiles to the series.", "extra-tip": "Assign reading profiles via the action menu on series and libraries, or in bulk. When changing settings in a reader, a hidden profile is created that remembers your choices for that series (not for pdfs). This profile is removed when you assign or update one of your own reading profiles to the series.",
"profiles-title": "Your reading profiles", "profiles-title": "Your reading profiles",
"default-profile": "Default", "default-profile": "Default",
"add": "{{common.add}}", "add": "{{common.add}}",