mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
Fixed a bug with user reviews (#2677)
This commit is contained in:
parent
828d62dfe9
commit
a9ab84803e
@ -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
|
||||
|
@ -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; }
|
||||
}
|
||||
|
@ -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>;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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": [
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user