Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug with user reviews #2677

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions API/Controllers/MetadataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public async Task<ActionResult<SeriesDetailPlusDto>> GetKavitaPlusSeriesDetailDa
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();

Expand All @@ -221,7 +221,13 @@ public async Task<ActionResult<SeriesDetailPlusDto>> GetKavitaPlusSeriesDetailDa
}

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
Expand Down
4 changes: 2 additions & 2 deletions API/DTOs/SeriesDetail/SeriesDetailPlusDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
4 changes: 2 additions & 2 deletions UI/Web/src/app/_models/series-detail/series-detail-plus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
});
this.setContinuePoint();

if (KavitaPlusSupportedLibraryTypes.includes(this.libraryType) && loadExternal) {
if (loadExternal) {
this.loadPlusMetadata(this.seriesId);
}

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
Loading