Skip to content

Commit ab09259

Browse files
author
Garrett Downs
committed
move updates check to new home view
1 parent 2472411 commit ab09259

2 files changed

Lines changed: 14 additions & 21 deletions

File tree

src/components/App.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ export default function App(): VNode {
5959

6060
// Core.health().then((res) => console.log(res));
6161

62-
// Core.checkForUpdates();
63-
// fetch(
64-
// 'http://localhost:8100/https://api.foxcasts.com/podcasts?feedUrl=https://feed.syntax.fm/rss'
65-
// )
66-
// .then((res) => console.log('res', res))
67-
// .catch((err) => console.log('err', err));
68-
6962
// Ensure default filters exist
7063
Core.filters.queryAll().then((res) => {
7164
if (res.length === 0) {

src/routes/Home.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { format } from 'date-fns';
1+
import { format, startOfDay } from 'date-fns';
22
import { EpisodeExtended, Podcast } from 'foxcasts-core/lib/types';
33
import { AppBar } from 'mai-ui/dist/components/appbar';
44
import { List, ListItem, ListSection } from 'mai-ui/dist/components/list';
@@ -25,14 +25,7 @@ export default function Home({ selectedItemId }: Props): h.JSX.Element {
2525
const favEpisodes = useFetchedState<EpisodeExtended[]>();
2626
const favPodcasts = useFetchedState<PodcastWithEpisodes[]>();
2727

28-
// console.log('favPodcasts', favPodcasts);
29-
// console.log('newEpisodes', newEpisodes);
30-
// console.log('favEpisodes', favEpisodes);
31-
3228
useEffect(() => {
33-
newEpisodes.getData(() =>
34-
Core.episodes.queryAll({ episodeIds: [352, 353] })
35-
);
3629
favEpisodes.getData(() =>
3730
Core.episodes.queryAll({ isFavorite: 1, limit: 5 })
3831
);
@@ -42,7 +35,7 @@ export default function Home({ selectedItemId }: Props): h.JSX.Element {
4235
for (const podcast of podcasts) {
4336
const episodes = await Core.episodes.queryAll({
4437
podcastIds: [podcast.id],
45-
limit: 2,
38+
limit: 1,
4639
});
4740
result.push({
4841
...podcast,
@@ -51,11 +44,12 @@ export default function Home({ selectedItemId }: Props): h.JSX.Element {
5144
}
5245
return result;
5346
});
54-
// Core.podcasts.checkForUpdates().then((res) => {
55-
// newEpisodes.getData(() =>
56-
// Core.episodes.queryAll({ episodeIds: res.episodeIds })
57-
// );
58-
// });
47+
newEpisodes.getData(async () => {
48+
await Core.podcasts.checkForUpdates();
49+
return Core.episodes.queryAll({
50+
afterDate: startOfDay(new Date()).toISOString(),
51+
});
52+
});
5953
}, []);
6054

6155
useListNav({
@@ -72,6 +66,12 @@ export default function Home({ selectedItemId }: Props): h.JSX.Element {
7266
<ViewContent>
7367
<ViewHeader>Home</ViewHeader>
7468
<Typography type="subtitle">Just Added</Typography>
69+
{newEpisodes.loading && (
70+
<Typography>Checking for new episodes...</Typography>
71+
)}
72+
{!newEpisodes.loading && newEpisodes.data?.length === 0 && (
73+
<Typography>Nothing new</Typography>
74+
)}
7575
<List>
7676
{newEpisodes.data?.map((episode) => (
7777
<ListItem

0 commit comments

Comments
 (0)