From 643c499f167b682d10d086e4e9ab8d64d27deefe Mon Sep 17 00:00:00 2001 From: Amelia <77553571+Fesaa@users.noreply.github.com> Date: Sun, 1 Jun 2025 15:21:01 +0200 Subject: [PATCH] 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 --- API/Controllers/AccountController.cs | 12 +++++------- API/Services/ReadingProfileService.cs | 1 + .../reader-settings/reader-settings.component.ts | 12 ++++++++---- .../manga-reader/manga-reader.component.ts | 7 +++++-- UI/Web/src/assets/langs/en.json | 2 +- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/API/Controllers/AccountController.cs b/API/Controllers/AccountController.cs index 66218390a..2828bf9a1 100644 --- a/API/Controllers/AccountController.cs +++ b/API/Controllers/AccountController.cs @@ -154,7 +154,7 @@ public class AccountController : BaseApiController AddDefaultStreamsToUser(user); // Assign default reading profile - AddDefaultReadingProfileToUser(user); + await AddDefaultReadingProfileToUser(user); var token = await _userManager.GenerateEmailConfirmationTokenAsync(user); if (string.IsNullOrEmpty(token)) return BadRequest(await _localizationService.Get("en", "confirm-token-gen")); @@ -673,7 +673,7 @@ public class AccountController : BaseApiController AddDefaultStreamsToUser(user); // Assign default reading profile - AddDefaultReadingProfileToUser(user); + await AddDefaultReadingProfileToUser(user); // Assign 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) .WithName("Default Profile") .Build(); - _unitOfWork.AppUserReadingProfileRepository.Attach(profile); + _unitOfWork.AppUserReadingProfileRepository.Add(profile); + await _unitOfWork.CommitAsync(); 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; } diff --git a/API/Services/ReadingProfileService.cs b/API/Services/ReadingProfileService.cs index 72ec9a39c..40a8fea4f 100644 --- a/API/Services/ReadingProfileService.cs +++ b/API/Services/ReadingProfileService.cs @@ -128,6 +128,7 @@ public class ReadingProfileService(IUnitOfWork unitOfWork, ILocalizationService var newProfile = new AppUserReadingProfileBuilder(user.Id).Build(); UpdateReaderProfileFields(newProfile, dto); unitOfWork.AppUserReadingProfileRepository.Add(newProfile); + user.UserPreferences.ReadingProfiles.Add(newProfile); await unitOfWork.CommitAsync(); diff --git a/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.ts b/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.ts index 76d023545..6c550b8ef 100644 --- a/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.ts +++ b/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.ts @@ -10,7 +10,7 @@ import { Output } from '@angular/core'; 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 { BookTheme } from 'src/app/_models/preferences/book-theme'; import { ReadingDirection } from 'src/app/_models/preferences/reading-direction'; @@ -210,7 +210,7 @@ export class ReaderSettingsComponent implements OnInit { this.setupSettings(); - this.setTheme(this.readingProfile.bookReaderThemeName || this.themeService.defaultBookTheme); + this.setTheme(this.readingProfile.bookReaderThemeName || this.themeService.defaultBookTheme, false); this.cdRef.markForCheck(); // Emit first time so book reader gets the setting @@ -288,6 +288,7 @@ export class ReaderSettingsComponent implements OnInit { this.settingsForm.valueChanges.pipe( debounceTime(300), distinctUntilChanged(), + skip(1), // Skip the initial creation of the form, we do not want an implicit profile of this snapshot takeUntilDestroyed(this.destroyRef), tap(_ => this.updateImplicit()) ).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); this.activeTheme = theme; this.cdRef.markForCheck(); this.colorThemeUpdate.emit(theme); - this.updateImplicit(); + + if (update) { + this.updateImplicit(); + } } toggleReadingDirection() { diff --git a/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.ts b/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.ts index a800bdf25..ebfcc84ad 100644 --- a/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.ts +++ b/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.ts @@ -25,6 +25,7 @@ import { merge, Observable, ReplaySubject, + skip, Subject, take, tap @@ -616,11 +617,11 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { this.init(); - // TODO: Fix this, it's going off way too often // Update implicit reading profile while changing settings this.generalSettingsForm.valueChanges.pipe( debounceTime(300), distinctUntilChanged(), + skip(1), // Skip the initial creation of the form, we do not want an implicit profile of this snapshot takeUntilDestroyed(this.destroyRef), map(_ => this.packReadingProfile()), distinctUntilChanged(), @@ -821,7 +822,9 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { disableDoubleRendererIfScreenTooSmall() { if (window.innerWidth > window.innerHeight) { - this.generalSettingsForm.get('layoutMode')?.enable(); + if (this.generalSettingsForm.get('layoutMode')?.disabled) { + this.generalSettingsForm.get('layoutMode')?.enable(); + } this.cdRef.markForCheck(); return; } diff --git a/UI/Web/src/assets/langs/en.json b/UI/Web/src/assets/langs/en.json index cd7ffe9bd..5af80694b 100644 --- a/UI/Web/src/assets/langs/en.json +++ b/UI/Web/src/assets/langs/en.json @@ -2803,7 +2803,7 @@ "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.", - "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", "default-profile": "Default", "add": "{{common.add}}",