From 10e4b318cbb21a4865229146a4eeefa38d583afa Mon Sep 17 00:00:00 2001 From: Joe Milazzo Date: Sat, 15 Apr 2023 06:58:54 -0500 Subject: [PATCH] Bugfixes from last PR (#1928) * Fixed a regression where confirm-email was validating for a real email when it's not required. * Fixed fit to screen breaking as canvas was still showing on the screen when it should have been hidden. * Fixed a missing age rating in the pipe * Fixed fit to height not properly aligning the image * Tweaked Startup check for base url --- API/Errors/ApiException.cs | 10 +++------ API/Startup.cs | 2 +- API/config/appsettings.Development.json | 2 +- Kavita.Common/EnvironmentInfo/IOsInfo.cs | 3 +-- UI/Web/src/_manga-reader-common.scss | 2 +- UI/Web/src/app/_models/stats/client-info.ts | 13 ----------- .../src/app/_models/stats/details-version.ts | 4 ---- .../manage-email-settings.component.ts | 3 ++- .../canvas-renderer.component.ts | 8 +++++++ .../single-renderer.component.html | 2 +- .../single-renderer.component.ts | 22 ++++++++++++++++--- UI/Web/src/app/pipe/age-rating.pipe.ts | 3 ++- .../confirm-email/confirm-email.component.ts | 2 +- openapi.json | 2 +- 14 files changed, 41 insertions(+), 37 deletions(-) delete mode 100644 UI/Web/src/app/_models/stats/client-info.ts delete mode 100644 UI/Web/src/app/_models/stats/details-version.ts diff --git a/API/Errors/ApiException.cs b/API/Errors/ApiException.cs index 8857f14a7..d9c1a755a 100644 --- a/API/Errors/ApiException.cs +++ b/API/Errors/ApiException.cs @@ -1,9 +1,5 @@ namespace API.Errors; -public record ApiException -{ - public ApiException(int status, string? message = null, string? details = null) - { - - } -} +#nullable enable +public record ApiException(int Status, string? Message = null, string? Details = null); +#nullable disable diff --git a/API/Startup.cs b/API/Startup.cs index e31633343..e916e1c50 100644 --- a/API/Startup.cs +++ b/API/Startup.cs @@ -401,7 +401,7 @@ public class Startup } catch (Exception ex) { - if (ex.Message.Contains("Permission denied") && baseUrl.Equals(Configuration.DefaultBaseUrl) && new OsInfo().IsDocker) + if ((ex.Message.Contains("Permission denied") || ex.Message.Contains("UnauthorizedAccessException")) && baseUrl.Equals(Configuration.DefaultBaseUrl) && new OsInfo().IsDocker) { // Swallow the exception as the install is non-root and Docker return; diff --git a/API/config/appsettings.Development.json b/API/config/appsettings.Development.json index cbf24d86b..2a9bbdd2c 100644 --- a/API/config/appsettings.Development.json +++ b/API/config/appsettings.Development.json @@ -2,5 +2,5 @@ "TokenKey": "super secret unguessable key", "Port": 5000, "IpAddresses": "", - "BaseUrl": "/test/" + "BaseUrl": "/" } \ No newline at end of file diff --git a/Kavita.Common/EnvironmentInfo/IOsInfo.cs b/Kavita.Common/EnvironmentInfo/IOsInfo.cs index e3453c3d6..54ec1500c 100644 --- a/Kavita.Common/EnvironmentInfo/IOsInfo.cs +++ b/Kavita.Common/EnvironmentInfo/IOsInfo.cs @@ -16,7 +16,7 @@ public class OsInfo : IOsInfo public static bool IsWindows => Os == Os.Windows; // this needs to not be static so we can mock it - public bool IsDocker { get; } + public bool IsDocker { get; private set; } public string Version { get; } public string Name { get; } @@ -41,7 +41,6 @@ public class OsInfo : IOsInfo break; } } - } public OsInfo(IEnumerable versionAdapters) diff --git a/UI/Web/src/_manga-reader-common.scss b/UI/Web/src/_manga-reader-common.scss index 5e385274d..ab9beb1d5 100644 --- a/UI/Web/src/_manga-reader-common.scss +++ b/UI/Web/src/_manga-reader-common.scss @@ -14,7 +14,7 @@ img { } &.full-height { - height: calc(100vh - $scrollbarHeight); + height: calc(100vh); // We need to - $scrollbarHeight when there is a horizontal scroll on macos display: flex; align-content: center; } diff --git a/UI/Web/src/app/_models/stats/client-info.ts b/UI/Web/src/app/_models/stats/client-info.ts deleted file mode 100644 index 67916b8cf..000000000 --- a/UI/Web/src/app/_models/stats/client-info.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { DetailsVersion } from "./details-version"; - - -export interface ClientInfo { - os: DetailsVersion, - browser: DetailsVersion, - platformType: string, - kavitaUiVersion: string, - screenResolution: string; - usingDarkTheme: boolean; - - collectedAt?: Date; -} diff --git a/UI/Web/src/app/_models/stats/details-version.ts b/UI/Web/src/app/_models/stats/details-version.ts deleted file mode 100644 index 10ce38263..000000000 --- a/UI/Web/src/app/_models/stats/details-version.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface DetailsVersion { - name: string; - version: string; -} \ No newline at end of file diff --git a/UI/Web/src/app/admin/manage-email-settings/manage-email-settings.component.ts b/UI/Web/src/app/admin/manage-email-settings/manage-email-settings.component.ts index d4b4045f9..dd436e010 100644 --- a/UI/Web/src/app/admin/manage-email-settings/manage-email-settings.component.ts +++ b/UI/Web/src/app/admin/manage-email-settings/manage-email-settings.component.ts @@ -67,7 +67,8 @@ export class ManageEmailSettingsComponent implements OnInit { } testEmailServiceUrl() { - this.settingsService.testEmailServerSettings(this.settingsForm.get('emailServiceUrl')?.value || '').pipe(take(1)).subscribe(async (result: EmailTestResult) => { + if (this.settingsForm.get('emailServiceUrl')?.value === '') return; + this.settingsService.testEmailServerSettings(this.settingsForm.get('emailServiceUrl')?.value).pipe(take(1)).subscribe(async (result: EmailTestResult) => { if (result.successful) { this.toastr.success('Email Service was reachable'); } else { diff --git a/UI/Web/src/app/manga-reader/_components/canvas-renderer/canvas-renderer.component.ts b/UI/Web/src/app/manga-reader/_components/canvas-renderer/canvas-renderer.component.ts index f6aca4bdc..7a539fa40 100644 --- a/UI/Web/src/app/manga-reader/_components/canvas-renderer/canvas-renderer.component.ts +++ b/UI/Web/src/app/manga-reader/_components/canvas-renderer/canvas-renderer.component.ts @@ -8,6 +8,8 @@ import { ReaderSetting } from '../../_models/reader-setting'; import { ImageRenderer } from '../../_models/renderer'; import { ManagaReaderService } from '../../_series/managa-reader.service'; +const ValidSplits = [PageSplitOption.SplitLeftToRight, PageSplitOption.SplitRightToLeft]; + @Component({ selector: 'app-canvas-renderer', templateUrl: './canvas-renderer.component.html', @@ -178,10 +180,16 @@ export class CanvasRendererComponent implements OnInit, AfterViewInit, OnDestroy if (!this.ctx || !this.canvas) return; this.canvasImage = img[0]; this.cdRef.markForCheck(); + + if (this.layoutMode !== LayoutMode.Single || !ValidSplits.includes(this.pageSplit)) { + return; + } const needsSplitting = this.updateSplitPage(); if (!needsSplitting) return; + // This is toggling true when manga reader shouldn't use this code + this.renderWithCanvas = true; if (this.currentImageSplitPart === SPLIT_PAGE_PART.NO_SPLIT) return; diff --git a/UI/Web/src/app/manga-reader/_components/single-renderer/single-renderer.component.html b/UI/Web/src/app/manga-reader/_components/single-renderer/single-renderer.component.html index db30021c6..2c203b263 100644 --- a/UI/Web/src/app/manga-reader/_components/single-renderer/single-renderer.component.html +++ b/UI/Web/src/app/manga-reader/_components/single-renderer/single-renderer.component.html @@ -1,6 +1,6 @@
+ [style.filter]="(darkenss$ | async) ?? '' | safeStyle" [style.height]="(imageContainerHeight$ | async) ?? '' | safeStyle">  = new EventEmitter(); imageFitClass$!: Observable; + imageContainerHeight$!: Observable; showClickOverlayClass$!: Observable; readerModeClass$!: Observable; darkenss$: Observable = of('brightness(100%)'); @@ -43,7 +44,7 @@ export class SingleRendererComponent implements OnInit, OnDestroy, ImageRenderer get LayoutMode() {return LayoutMode;} constructor(private readonly cdRef: ChangeDetectorRef, public mangaReaderService: ManagaReaderService, - @Inject(DOCUMENT) private document: Document, private readerService: ReaderService) { } + @Inject(DOCUMENT) private document: Document) { } ngOnInit(): void { this.readerModeClass$ = this.readerSettings$.pipe( @@ -53,13 +54,28 @@ export class SingleRendererComponent implements OnInit, OnDestroy, ImageRenderer takeUntil(this.onDestroy) ); + this.imageContainerHeight$ = this.readerSettings$.pipe( + map(values => values.fitting), + map(mode => { + if ( mode !== FITTING_OPTION.HEIGHT) return ''; + + const readingArea = this.document.querySelector('.reading-area'); + if (!readingArea) return 'calc(100vh)'; + + if (this.currentImage.width - readingArea.scrollWidth > 0) { + return 'calc(100vh - 34px)' + } + return 'calc(100vh)' + }), + filter(_ => this.isValid()), + takeUntil(this.onDestroy) + ); + this.pageNum$.pipe( takeUntil(this.onDestroy), tap(pageInfo => { this.pageNum = pageInfo.pageNum; this.maxPages = pageInfo.maxPages; - - // TODO: Put this here this.currentImage = this.getPagez }), ).subscribe(() => {}); diff --git a/UI/Web/src/app/pipe/age-rating.pipe.ts b/UI/Web/src/app/pipe/age-rating.pipe.ts index eee1b9e32..97bdedcf6 100644 --- a/UI/Web/src/app/pipe/age-rating.pipe.ts +++ b/UI/Web/src/app/pipe/age-rating.pipe.ts @@ -26,7 +26,8 @@ export class AgeRatingPipe implements PipeTransform { case AgeRating.G: return of('G'); case AgeRating.KidsToAdults: return of('Kids to Adults'); case AgeRating.Mature: return of('Mature'); - case AgeRating.Mature17Plus: return of('M'); + case AgeRating.Mature15Plus: return of('MA15+'); + case AgeRating.Mature17Plus: return of('Mature 17+'); case AgeRating.RatingPending: return of('Rating Pending'); case AgeRating.Teen: return of('Teen'); case AgeRating.X18Plus: return of('X18+'); diff --git a/UI/Web/src/app/registration/_components/confirm-email/confirm-email.component.ts b/UI/Web/src/app/registration/_components/confirm-email/confirm-email.component.ts index 39b50cdbc..d32fc8b68 100644 --- a/UI/Web/src/app/registration/_components/confirm-email/confirm-email.component.ts +++ b/UI/Web/src/app/registration/_components/confirm-email/confirm-email.component.ts @@ -19,7 +19,7 @@ export class ConfirmEmailComponent { token: string = ''; registerForm: FormGroup = new FormGroup({ - email: new FormControl('', [Validators.required, Validators.email]), + email: new FormControl('', [Validators.required]), username: new FormControl('', [Validators.required]), password: new FormControl('', [Validators.required, Validators.maxLength(32), Validators.minLength(6), Validators.pattern("^.{6,32}$")]), }); diff --git a/openapi.json b/openapi.json index 2c8cf5416..e78d30681 100644 --- a/openapi.json +++ b/openapi.json @@ -7,7 +7,7 @@ "name": "GPL-3.0", "url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE" }, - "version": "0.7.1.34" + "version": "0.7.1.35" }, "servers": [ {