may update ytb channels via api

This commit is contained in:
an-lee
2024-07-23 17:42:08 +08:00
parent 7d9938c3cb
commit 3b884c1fb6

View File

@@ -6,8 +6,26 @@ import {
YoutubeVideosSegment,
EnrollmentSegment,
} from "@renderer/components";
import { useContext, useEffect, useState } from "react";
import { AppSettingsProviderContext } from "@renderer/context";
export default () => {
const [channels, setChannels] = useState<string[]>([
"@TED",
"@CNN",
"@nytimes",
]);
const { webApi } = useContext(AppSettingsProviderContext);
useEffect(() => {
webApi.config("ytb_channels").then((channels) => {
if (!channels) return;
setChannels(channels);
});
}, []);
return (
<div className="max-w-5xl mx-auto px-4 py-6 lg:px-8">
<div className="space-y-4">
@@ -16,9 +34,9 @@ export default () => {
<VideosSegment />
<StoriesSegment />
<AudibleBooksSegment />
<YoutubeVideosSegment channel="@TED" />
<YoutubeVideosSegment channel="@CNN" />
<YoutubeVideosSegment channel="@nytimes" />
{channels.map((channel) => (
<YoutubeVideosSegment key={channel} channel={channel} />
))}
</div>
</div>
);