Add setting/toggle to automatically download reviews (#1221)

This commit is contained in:
Aditya Chandel
2025-09-26 14:39:52 -06:00
committed by GitHub
parent a9c1be9854
commit 06523d4c24
10 changed files with 124 additions and 31 deletions
@@ -6,14 +6,32 @@
<span class="text-gray-400">Getting latest reviews...</span>
</div>
} @else if (reviews?.length === 0) {
<div class="text-center p-8 text-gray-400">
<i class="pi pi-comments text-4xl mb-4 block"></i>
<p class="text-gray-200">No reviews available for this book</p>
<div class="text-center p-8 text-gray-400 empty-state">
<div class="empty-state-icon">
@if (hasPermission && !reviewsLocked && reviewDownloadEnabled) {
<p-button
outlined
rounded
icon="pi pi-download"
severity="primary"
(click)="fetchNewReviews()"
pTooltip="Fetch Reviews"
tooltipPosition="top"
class="action-btn floating-btn">
</p-button>
}
</div>
<p class="text-gray-200 empty-state-title">No reviews available for this book</p>
@if (!reviewDownloadEnabled) {
<p class="text-sm text-amber-400 mt-2">
<p class="text-sm text-amber-400 mt-2 empty-state-subtitle">
Book review downloads are currently disabled. Enable this in Metadata Settings to fetch reviews.
</p>
} @else if (hasPermission && !reviewsLocked) {
<p class="text-sm text-gray-400 mt-2 empty-state-subtitle">
Click "Fetch Reviews" to download reviews from configured providers
</p>
}
<div class="empty-state-decoration"></div>
</div>
} @else {
<div class="reviews-scroll-container">
@@ -54,6 +54,35 @@
}
}
.empty-state {
position: relative;
padding: 3rem !important;
.empty-state-title {
font-size: 1.25rem;
font-weight: 600;
margin-top: 1rem;
margin-bottom: 0.5rem;
}
.empty-state-subtitle {
max-width: 400px;
margin: 0 auto;
line-height: 1.6;
}
.empty-state-decoration {
position: absolute;
top: 20%;
right: 15%;
width: 100px;
height: 100px;
border-radius: 50%;
filter: blur(40px);
animation: float 4s ease-in-out infinite;
}
}
.reviews-scroll-container {
overflow-x: auto;
overflow-y: hidden;
@@ -94,6 +94,7 @@ export interface ReviewProviderConfig {
export interface PublicReviewSettings {
downloadEnabled: boolean;
autoDownloadEnabled: boolean;
providers: ReviewProviderConfig[];
}
@@ -10,12 +10,28 @@
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Automatically download user reviews from enabled platforms (Amazon, Goodreads, Hardcover) when fetching book metadata. Reviews will be stored with your books for offline access.
Enable downloading user reviews from configured platforms (Amazon, Goodreads, Hardcover). Reviews will be stored with your books for offline access.
</p>
</div>
</div>
@if (publicReviewSettings.downloadEnabled) {
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Auto Download on Book Open</label>
<p-toggleswitch
[(ngModel)]="publicReviewSettings.autoDownloadEnabled"
(onChange)="onAutoDownloadToggle($event.checked)">
</p-toggleswitch>
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Automatically fetch reviews when you open a book's details page. When disabled, reviews will only be downloaded manually or during metadata refresh, reducing background network activity and improving performance.
</p>
</div>
</div>
<div class="review-sources-section">
<div class="sources-header">
<h4 class="subsection-title">Review Sources</h4>
@@ -25,6 +25,7 @@ export class PublicReviewsSettingsComponent implements OnInit {
publicReviewSettings: PublicReviewSettings = {
downloadEnabled: true,
autoDownloadEnabled: false,
providers: [...DEFAULT_PROVIDERS]
};
@@ -42,6 +43,11 @@ export class PublicReviewsSettingsComponent implements OnInit {
this.settingsHelper.saveSetting(AppSettingKey.METADATA_PUBLIC_REVIEWS_SETTINGS, this.publicReviewSettings);
}
onAutoDownloadToggle(checked: boolean): void {
this.publicReviewSettings.autoDownloadEnabled = checked;
this.settingsHelper.saveSetting(AppSettingKey.METADATA_PUBLIC_REVIEWS_SETTINGS, this.publicReviewSettings);
}
onProviderToggle(providerName: string, enabled: boolean): void {
this.updateProviderProperty(providerName, 'enabled', enabled);
}