diff --git a/materialious/src/lib/api/youtubejs/subscriptions.ts b/materialious/src/lib/api/youtubejs/subscriptions.ts index d3126752..995f0640 100644 --- a/materialious/src/lib/api/youtubejs/subscriptions.ts +++ b/materialious/src/lib/api/youtubejs/subscriptions.ts @@ -65,7 +65,7 @@ export async function parseChannelRSS(channelId: string): Promise { entry.getElementsByTagName('published')[0]?.textContent || new Date() ); const published = publishedAt.getTime(); - const publishedText = relativeTimestamp(published); + const publishedText = relativeTimestamp(published, false); const author = entry.getElementsByTagName('author')[0]?.getElementsByTagName('name')[0]?.textContent || 'Unknown Author'; @@ -131,16 +131,22 @@ export async function parseChannelRSS(channelId: string): Promise { export async function getFeedYTjs(maxResults: number, page: number): Promise { const channelSubscriptions = await localDb.channelSubscriptions.toArray(); + const toUpdatePromises: Promise[] = []; + const now = new Date(); for (const channel of channelSubscriptions) { const lastRSSFetch = new Date(channel.lastRSSFetch); const timeDifference = now.getTime() - lastRSSFetch.getTime(); const oneDayInMillis = 6 * 60 * 60 * 1000; if (timeDifference > oneDayInMillis) { - parseChannelRSS(channel.channelId); + toUpdatePromises.push(parseChannelRSS(channel.channelId)); } } + if (toUpdatePromises) { + await Promise.all(toUpdatePromises); + } + const videos = await localDb.subscriptionFeed.toArray(); videos.sort((a, b) => b.published - a.published); diff --git a/materialious/src/lib/components/Thumbnail.svelte b/materialious/src/lib/components/Thumbnail.svelte index 3db2b316..b0d76a44 100644 --- a/materialious/src/lib/components/Thumbnail.svelte +++ b/materialious/src/lib/components/Thumbnail.svelte @@ -23,6 +23,7 @@ synciousStore } from '../store'; import { queueGetWatchProgress } from '$lib/api/apiExtended'; + import { relativeTimestamp } from '$lib/time'; interface Props { video: VideoBase | Video | Notification | PlaylistPageVideo; @@ -175,7 +176,9 @@ {#if !thumbnail}
{:else} - Thumbnail for video +
180}> + Thumbnail for video +
{/if} {/if} {#if progress} @@ -243,9 +246,12 @@ {$_('views')} {/if} - {#if 'publishedText' in video} + {#if 'published' in video}
- {video.viewCountText ?? cleanNumber(video.viewCount ?? 0)} • {video.publishedText} + {video.viewCountText ?? cleanNumber(video.viewCount ?? 0)} • {relativeTimestamp( + video.published, + false + )}
{/if} @@ -254,6 +260,22 @@