Trim whitespace in certain string fields for better overview

Fixed ASIN-Search
fixes #2605
This commit is contained in:
bloedboemmel 2024-02-12 12:18:48 +00:00
parent ce7f81d676
commit 3b2b72c6da
5 changed files with 7 additions and 5 deletions

View file

@ -451,6 +451,7 @@ class BookFinder {
}
findChapters(asin, region) {
asin = asin.trim()
return this.audnexus.getChaptersByASIN(asin, region)
}
}

View file

@ -35,7 +35,7 @@ class Author extends Model {
return new oldAuthor({
id: this.id,
asin: this.asin,
name: this.name,
name: this.name.trim(),
description: this.description,
imagePath: this.imagePath,
libraryId: this.libraryId,
@ -66,7 +66,7 @@ class Author extends Model {
static getFromOld(oldAuthor) {
return {
id: oldAuthor.id,
name: oldAuthor.name,
name: oldAuthor.name.trim(),
lastFirst: oldAuthor.lastFirst,
asin: oldAuthor.asin,
description: oldAuthor.description,

View file

@ -232,7 +232,7 @@ class Book extends Model {
chapters: this.chapters?.map(c => ({ ...c })) || [],
title: this.title,
subtitle: this.subtitle,
authors: this.authors.map(a => a.name),
authors: this.authors.map(a => a.name.trim()),
narrators: this.narrators,
series: this.series.map(se => {
const sequence = se.bookSeries?.sequence || ''

View file

@ -351,7 +351,8 @@ class LibraryItem extends Model {
for (const key in updatedMedia) {
let existingValue = libraryItemExpanded.media[key]
if (existingValue instanceof Date) existingValue = existingValue.valueOf()
// Check for trimming. Why not instanceof? var str = "string" isn't instance of String
if (typeof updatedMedia[key] === "string") updatedMedia[key] = updatedMedia[key].trim()
if (!areEquivalent(updatedMedia[key], existingValue, true)) {
Logger.debug(`[LibraryItem] "${libraryItemExpanded.media.title}" ${libraryItemExpanded.mediaType}.${key} updated from ${existingValue} to ${updatedMedia[key]}`)
hasMediaUpdates = true

View file

@ -30,7 +30,7 @@ class Series extends Model {
getOldSeries() {
return new oldSeries({
id: this.id,
name: this.name,
name: this.name.trim(),
description: this.description,
libraryId: this.libraryId,
addedAt: this.createdAt.valueOf(),