Fix episode list
This commit is contained in:
@ -8,6 +8,7 @@ import {
|
||||
deleteFeed,
|
||||
toggleFeedActive,
|
||||
getFeedByUrl,
|
||||
getFeedById,
|
||||
fetchAllEpisodes,
|
||||
fetchEpisodesWithArticles,
|
||||
getFeedRequests,
|
||||
|
@ -27,10 +27,15 @@ function EpisodeList() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const response = await fetch('/api/episodes')
|
||||
if (!response.ok) throw new Error('エピソードの取得に失敗しました')
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json()
|
||||
throw new Error(errorData.error || 'エピソードの取得に失敗しました')
|
||||
}
|
||||
const data = await response.json()
|
||||
console.log('Fetched episodes:', data)
|
||||
setEpisodes(data)
|
||||
} catch (err) {
|
||||
console.error('Episode fetch error:', err)
|
||||
setError(err instanceof Error ? err.message : 'エラーが発生しました')
|
||||
} finally {
|
||||
setLoading(false)
|
||||
@ -64,7 +69,14 @@ function EpisodeList() {
|
||||
return (
|
||||
<div className="empty-state">
|
||||
<p>エピソードがありません</p>
|
||||
<p>フィード管理でRSSフィードを追加してください</p>
|
||||
<p>フィードリクエストでRSSフィードをリクエストするか、管理者にバッチ処理の実行を依頼してください</p>
|
||||
<button
|
||||
className="btn btn-secondary"
|
||||
onClick={fetchEpisodes}
|
||||
style={{ marginTop: '10px' }}
|
||||
>
|
||||
再読み込み
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import { generateTTS } from "../services/tts.js";
|
||||
import {
|
||||
saveFeed,
|
||||
getFeedByUrl,
|
||||
getFeedById,
|
||||
saveArticle,
|
||||
getUnprocessedArticles,
|
||||
markArticleAsProcessed,
|
||||
@ -294,7 +295,7 @@ async function generatePodcastForArticle(article: any): Promise<void> {
|
||||
|
||||
try {
|
||||
// Get feed information for context
|
||||
const feed = await getFeedByUrl(article.feedId);
|
||||
const feed = await getFeedById(article.feedId);
|
||||
const feedTitle = feed?.title || "Unknown Feed";
|
||||
|
||||
// Classify the article/feed
|
||||
|
@ -193,6 +193,27 @@ export async function getFeedByUrl(url: string): Promise<Feed | null> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getFeedById(id: string): Promise<Feed | null> {
|
||||
try {
|
||||
const stmt = db.prepare("SELECT * FROM feeds WHERE id = ?");
|
||||
const row = stmt.get(id) as any;
|
||||
if (!row) return null;
|
||||
|
||||
return {
|
||||
id: row.id,
|
||||
url: row.url,
|
||||
title: row.title,
|
||||
description: row.description,
|
||||
lastUpdated: row.last_updated,
|
||||
createdAt: row.created_at,
|
||||
active: Boolean(row.active),
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error getting feed by ID:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAllFeeds(): Promise<Feed[]> {
|
||||
try {
|
||||
const stmt = db.prepare(
|
||||
|
Reference in New Issue
Block a user