From ca20e5411549ca3c88b86bbb557c22abb945d71b Mon Sep 17 00:00:00 2001 From: Stefan Hardegger Date: Fri, 5 Jun 2026 20:38:44 +0200 Subject: [PATCH] rating display fix & directory mapping --- docker-compose.yml | 19 ++--- frontend/src/components/stories/StoryCard.tsx | 8 ++- .../src/components/stories/StoryRating.tsx | 2 +- migrate-volumes.sh | 69 +++++++++++++++++++ 4 files changed, 83 insertions(+), 15 deletions(-) create mode 100644 migrate-volumes.sh diff --git a/docker-compose.yml b/docker-compose.yml index 2a71f05..bd46025 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: ports: - "6925:80" volumes: - - images_data:/app/images:ro + - /volume1/docker/storycove/images:/app/images:ro configs: - source: nginx_config target: /etc/nginx/nginx.conf @@ -42,9 +42,9 @@ services: - APP_PASSWORD=${APP_PASSWORD} - STORYCOVE_CORS_ALLOWED_ORIGINS=${STORYCOVE_CORS_ALLOWED_ORIGINS:-http://localhost:3000,http://localhost:6925} volumes: - - images_data:/app/images - - library_config:/app/config - - automatic_backups:/app/automatic-backups + - /volume1/docker/storycove/images:/app/images + - /volume1/docker/storycove/config:/app/config + - /volume1/docker/storycove/backups:/app/automatic-backups depends_on: postgres: condition: service_healthy @@ -63,7 +63,7 @@ services: - POSTGRES_USER=storycove - POSTGRES_PASSWORD=${DB_PASSWORD} volumes: - - postgres_data:/var/lib/postgresql/data + - /volume1/docker/storycove/postgres:/var/lib/postgresql/data networks: - storycove-network healthcheck: @@ -83,7 +83,7 @@ services: - SOLR_HEAP=512m - SOLR_JAVA_MEM=-Xms256m -Xmx512m volumes: - - solr_data:/var/solr + - /volume1/docker/storycove/solr:/var/solr deploy: resources: limits: @@ -102,13 +102,6 @@ services: restart: unless-stopped -volumes: - postgres_data: - solr_data: - images_data: - library_config: - automatic_backups: - configs: nginx_config: content: | diff --git a/frontend/src/components/stories/StoryCard.tsx b/frontend/src/components/stories/StoryCard.tsx index e3730a3..64c011a 100644 --- a/frontend/src/components/stories/StoryCard.tsx +++ b/frontend/src/components/stories/StoryCard.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import Link from 'next/link'; import Image from 'next/image'; import { Story } from '../../types/api'; @@ -49,6 +49,12 @@ export default function StoryCard({ const [rating, setRating] = useState(story.rating || 0); const [updating, setUpdating] = useState(false); + // Sync rating state when a different story is rendered in the same component slot, + // or when the story's rating is updated externally (e.g. from the detail page). + useEffect(() => { + setRating(story.rating || 0); + }, [story.id, story.rating]); + // Helper function to get tags from either tags array or tagNames array const getTags = () => { if (Array.isArray(story.tags) && story.tags.length > 0) { diff --git a/frontend/src/components/stories/StoryRating.tsx b/frontend/src/components/stories/StoryRating.tsx index bf00606..4661d97 100644 --- a/frontend/src/components/stories/StoryRating.tsx +++ b/frontend/src/components/stories/StoryRating.tsx @@ -37,7 +37,7 @@ export default function StoryRating({ } }; - const displayRating = hoveredRating || rating; + const displayRating = hoveredRating || (rating || 0); return (
diff --git a/migrate-volumes.sh b/migrate-volumes.sh new file mode 100644 index 0000000..ea5e340 --- /dev/null +++ b/migrate-volumes.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# Migration script: move StoryCove Docker volume data to new NAS directories. +# Run this on the NAS as root (or with sudo) BEFORE restarting the stack. + +set -euo pipefail + +SRC_BASE="/volume1/@docker/volumes" +DST_BASE="/volume1/docker/storycove" + +declare -A VOLUMES=( + ["storycove_solr_data/_data"]="solr" + ["storycove_postgres_data/_data"]="postgres" + ["storycove_library_config/_data"]="config" + ["storycove_images_data/_data"]="images" + ["storycove_automatic_backups/_data"]="backups" +) + +echo "=== StoryCove volume migration ===" +echo "" + +# Verify source directories exist +for src_rel in "${!VOLUMES[@]}"; do + src="$SRC_BASE/$src_rel" + if [ ! -d "$src" ]; then + echo "ERROR: Source directory not found: $src" + exit 1 + fi +done + +# Create destination directories if they don't exist +for dst_rel in "${VOLUMES[@]}"; do + dst="$DST_BASE/$dst_rel" + if [ ! -d "$dst" ]; then + echo "Creating directory: $dst" + mkdir -p "$dst" + fi +done + +echo "" +echo "Stopping StoryCove stack (docker compose down)..." +cd "$(dirname "$0")" +docker compose down + +echo "" +echo "Migrating data..." + +for src_rel in "${!VOLUMES[@]}"; do + dst_rel="${VOLUMES[$src_rel]}" + src="$SRC_BASE/$src_rel" + dst="$DST_BASE/$dst_rel" + + echo "" + echo " $src" + echo " -> $dst" + + rsync -a --info=progress2 "$src/" "$dst/" +done + +echo "" +echo "Migration complete." +echo "" +echo "Old volume directories have NOT been deleted." +echo "Once you have verified the stack works correctly, you can remove them with:" +echo "" +for src_rel in "${!VOLUMES[@]}"; do + echo " rm -rf \"$SRC_BASE/$src_rel\"" +done +echo "" +echo "Start the stack again with: docker compose up -d"