Fixed a bug with user reviews (#2677)

This commit is contained in:
Joe Milazzo 2024-02-01 14:30:44 -06:00 committed by GitHub
parent 828d62dfe9
commit a9ab84803e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 10 deletions

View File

@ -207,7 +207,7 @@ public class MetadataController(IUnitOfWork unitOfWork, ILocalizationService loc
if (user == null) return Unauthorized();
var userReviews = (await unitOfWork.UserRepository.GetUserRatingDtosForSeriesAsync(seriesId, user.Id))
.Where(r => !string.IsNullOrEmpty(r.Body))
.Where(r => !string.IsNullOrEmpty(r.BodyJustText))
.OrderByDescending(review => review.Username.Equals(user.UserName) ? 1 : 0)
.ToList();
@ -221,7 +221,13 @@ public class MetadataController(IUnitOfWork unitOfWork, ILocalizationService loc
}
var ret = await metadataService.GetSeriesDetail(user.Id, seriesId);
if (ret == null) return Ok(null);
if (ret == null) return Ok(new SeriesDetailPlusDto()
{
Reviews = userReviews,
Recommendations = null,
Ratings = null
});
await _cacheProvider.SetAsync(cacheKey, ret, TimeSpan.FromHours(48));
// For some reason if we don't use a different instance, the cache keeps changes made below

View File

@ -9,7 +9,7 @@ namespace API.DTOs.SeriesDetail;
/// <remarks>This is what the UI sees, not what the API sends back</remarks>
public class SeriesDetailPlusDto
{
public RecommendationDto Recommendations { get; set; }
public RecommendationDto? Recommendations { get; set; }
public IEnumerable<UserReviewDto> Reviews { get; set; }
public IEnumerable<RatingDto> Ratings { get; set; }
public IEnumerable<RatingDto>? Ratings { get; set; }
}

View File

@ -3,7 +3,7 @@ import {UserReview} from "../../_single-module/review-card/user-review";
import {Rating} from "../rating";
export interface SeriesDetailPlus {
recommendations: Recommendation;
recommendations?: Recommendation;
reviews: Array<UserReview>;
ratings: Array<Rating>;
ratings?: Array<Rating>;
}

View File

@ -587,7 +587,7 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
});
this.setContinuePoint();
if (KavitaPlusSupportedLibraryTypes.includes(this.libraryType) && loadExternal) {
if (loadExternal) {
this.loadPlusMetadata(this.seriesId);
}
@ -701,10 +701,16 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
// Reviews
this.reviews = [...data.reviews];
this.ratings = [...data.ratings];
if (data.ratings) {
this.ratings = [...data.ratings];
}
// Recommendations
this.combinedRecs = [...data.recommendations.ownedSeries, ...data.recommendations.externalSeries];
if (data.recommendations) {
this.combinedRecs = [...data.recommendations.ownedSeries, ...data.recommendations.externalSeries];
}
this.hasRecommendations = this.combinedRecs.length > 0;
this.cdRef.markForCheck();

View File

@ -7,7 +7,7 @@
"name": "GPL-3.0",
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
},
"version": "0.7.13.12"
"version": "0.7.13.13"
},
"servers": [
{