diff --git a/src/routes/watchlist/stocks/+page.svelte b/src/routes/watchlist/stocks/+page.svelte index d3283849..d6522d07 100644 --- a/src/routes/watchlist/stocks/+page.svelte +++ b/src/routes/watchlist/stocks/+page.svelte @@ -21,6 +21,7 @@ let watchList: any[] = []; let news = []; + let groupedNews = {}; let checkedItems; let socket; @@ -213,6 +214,22 @@ watchList = output?.data; news = output?.news; + news = news?.map((item) => { + const match = watchList?.find((w) => w?.symbol === item?.symbol); + return match ? { ...item, type: match?.type } : { ...item }; + }); + groupedNews = Object?.entries( + news?.reduce((acc, item) => { + const dateKey = new Intl.DateTimeFormat("en-US", { + day: "2-digit", + month: "short", + year: "numeric", + }).format(new Date(item?.publishedDate)); + if (!acc[dateKey]) acc[dateKey] = []; + acc[dateKey]?.push(item); + return acc; + }, {}), + ); } async function createWatchList(event) { @@ -1319,70 +1336,96 @@
-- {new URL(item?.url).hostname.replace( - "www.", - "", - )} -
-
- - {item?.text?.length > 250 - ? item?.text?.slice(0, 250) + "..." - : item?.text} -
-