This commit is contained in:
MuslemRahimi 2024-07-27 23:19:49 +02:00
parent 19d9b47e32
commit 9a60889db3
4 changed files with 76 additions and 63 deletions

View File

@ -7,7 +7,7 @@ async function loadNotifications(fastifyURL:string, userId:string) {
const response = await fetch(fastifyURL+'/get-notifications', { const response = await fetch(fastifyURL+'/get-notifications', {
method: 'POST', method: 'POST',
headers: { headers: {
"Content-Type": "application/json","X-API-KEY": apiKey "Content-Type": "application/json"
}, },
body: JSON.stringify(postData) body: JSON.stringify(postData)
}); });
@ -28,7 +28,6 @@ async function loadNotifications(fastifyURL:string, userId:string) {
const numberOfUnreadNotification = notificationList?.length const numberOfUnreadNotification = notificationList?.length
const hasUnreadElement = notificationList?.length !== 0 ? true : false; const hasUnreadElement = notificationList?.length !== 0 ? true : false;
const output = {notificationList, hasUnreadElement, numberOfUnreadNotification} const output = {notificationList, hasUnreadElement, numberOfUnreadNotification}
postMessage({ message: 'success', output}); postMessage({ message: 'success', output});

View File

@ -39,7 +39,7 @@
import Boxes from "lucide-svelte/icons/boxes"; import Boxes from "lucide-svelte/icons/boxes";
import Newspaper from "lucide-svelte/icons/newspaper"; import Newspaper from "lucide-svelte/icons/newspaper";
import MessageCircle from "lucide-svelte/icons/message-circle"; import MessageCircle from "lucide-svelte/icons/message-circle";
import AudioLine from "lucide-svelte/icons/audio-lines";
export let data; export let data;
@ -79,24 +79,6 @@ async function detectSWUpdate() {
$userRegion = data?.region?.split("::")[0]; $userRegion = data?.region?.split("::")[0];
let collapse = false;
const usRegion = ['cle1','iad1','pdx1','sfo1'];
let fastifyURL;
userRegion.subscribe(value => {
if (usRegion?.includes(value)) {
fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL;
} else {
fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL;
}
});
let hideHeader = false; let hideHeader = false;
NProgress.configure({ showSpinner: false }); NProgress.configure({ showSpinner: false });
@ -124,19 +106,6 @@ async function detectSWUpdate() {
let hasUnreadElement = false; let hasUnreadElement = false;
let notificationList = []; let notificationList = [];
function handleCollapse() {
if ($screenWidth > 640)
{
collapse = !collapse
stockGuide = false;
etfGuide = false;
optionsGuide = false;
calendarGuide = false;
}
}
//Define web workers: //Define web workers:
let syncWorker: Worker | undefined = undefined; let syncWorker: Worker | undefined = undefined;
@ -164,8 +133,7 @@ const loadWorker = async () => {
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
const SyncWorker = await import('$lib/workers/notificationWorker?worker'); const SyncWorker = await import('$lib/workers/notificationWorker?worker');
syncWorker = new SyncWorker.default(); syncWorker = new SyncWorker.default();
syncWorker.postMessage({ message: {'fastifyURL': data?.fastifyURL, 'userId': data?.user?.id }});
syncWorker.postMessage({ message: {'fastifyURL': fastifyURL, 'userId': data?.user?.id }});
syncWorker.onmessage = handleMessage; syncWorker.onmessage = handleMessage;
} else { } else {
// Fallback logic here // Fallback logic here
@ -180,10 +148,10 @@ async function fallbackWorker() {
console.log('Fallback worker activated'); console.log('Fallback worker activated');
const postData = {'userId': data?.user?.id}; const postData = {'userId': data?.user?.id};
const response = await fetch(fastifyURL+'/get-notifications', { const response = await fetch(data?.fastifyURL+'/get-notifications', {
method: 'POST', method: 'POST',
headers: { headers: {
"Content-Type": "application/json"
}, },
body: JSON.stringify(postData) body: JSON.stringify(postData)
}); });
@ -212,21 +180,11 @@ $showCookieConsent = typeof data?.cookieConsent !== 'undefined' ? false : true;
onMount(async () => { onMount(async () => {
await loadWorker(); await loadWorker();
//await pushNotification() //await pushNotification()
if($showCookieConsent === true) { if($showCookieConsent === true) {
Cookie = (await import("$lib/components/Cookie.svelte")).default; Cookie = (await import("$lib/components/Cookie.svelte")).default;
} }
//await loadTwitchWorker();
/*
if (window.innerWidth <= 768) {
detectSWUpdate();
}
*/
}) })
@ -261,9 +219,6 @@ $: {
} }
let innerWidth; let innerWidth;
@ -297,16 +252,12 @@ $: {
} }
} }
$: {
if($screenWidth < 1536)
{
collapse = false;
}
}
</script> </script>
<svelte:window bind:innerWidth/> <svelte:window bind:innerWidth/>
<svelte:options immutable = {true} />
<div class="app {$page?.url?.pathname === '/' ? 'bg-[#000]' : ''}"> <div class="app {$page?.url?.pathname === '/' ? 'bg-[#000]' : ''}">
@ -507,6 +458,31 @@ $: {
</Accordion.Root> </Accordion.Root>
</div> </div>
<div class="flex flex-row items-center ml-9 w-full mt-3">
<Accordion.Root class="w-full">
<Accordion.Item value="item-1">
<Accordion.Trigger class="">
<AudioLine class="h-5.5 w-5.5 mr-3 text-white ml-1"/>
<span class="text-white ml-1 mr-auto">Tracker Datasets</span>
</Accordion.Trigger>
<Accordion.Content class="border-l border-gray-500 ml-2 mt-5">
<div class="flex flex-col items-start">
<a href="/cramer-tracker" class="text-[1rem] text-white ml-4 mt-4">Jim Cramer Tracker</a>
<a href="/most-retail-volume" class="text-[1rem] text-white ml-4 mt-4">Retail Trader Tracker</a>
<a href="/reddit-tracker" class="text-[1rem] text-white ml-4 mt-4">Reddit Tracker</a>
</div>
</Accordion.Content
>
</Accordion.Item>
</Accordion.Root>
</div>
<!-- <!--
<a href="/dark-pool-flow" class="flex flex-row items-center ml-9 w-full mt-3"> <a href="/dark-pool-flow" class="flex flex-row items-center ml-9 w-full mt-3">
<div <div
@ -797,7 +773,45 @@ $: {
</Accordion.Root> </Accordion.Root>
</div> </div>
<!--
<div class="flex flex-row items-center w-full">
<Accordion.Root class="w-full">
<Accordion.Item value="item-1">
<Accordion.Trigger class="">
<AudioLine class="h-5.5 w-5.5 mr-3 text-white ml-1"/>
<span class="text-white ml-1 mr-auto">Tracker Datasets</span>
</Accordion.Trigger>
<Accordion.Content class="border-l border-gray-500 ml-2 mt-5">
<Sheet.Close asChild let:builder>
<div class="flex flex-col items-start">
<Button builders={[builder]} type="submit" class="bg-[#141417] hover:bg-[#141417]">
<a href="/cramer-tracker" class="text-[1rem] text-white ml-4 mt-2">Jim Cramer Tracker</a>
</Button>
<Button builders={[builder]} type="submit" class="bg-[#141417] hover:bg-[#141417]">
<a href="/most-retail-volume" class="text-[1rem] text-white ml-4 mt-4">Retail Trader Tracker</a>
</Button>
<Button builders={[builder]} type="submit" class="bg-[#141417] hover:bg-[#141417]">
<a href="/reddit-tracker" class="text-[1rem] text-white ml-4 mt-4">Reddit Tracker</a>
</Button>
</div>
</Sheet.Close>
</Accordion.Content
>
</Accordion.Item>
</Accordion.Root>
</div>
<!--
<Sheet.Close asChild let:builder> <Sheet.Close asChild let:builder>
<Button builders={[builder]} type="submit" class="bg-[#141417] hover:bg-[#141417] -ml-4 w-full"> <Button builders={[builder]} type="submit" class="bg-[#141417] hover:bg-[#141417] -ml-4 w-full">
<a href="/dark-pool-flow" class="flex flex-row items-center w-full -mt-2"> <a href="/dark-pool-flow" class="flex flex-row items-center w-full -mt-2">

View File

@ -295,7 +295,7 @@ const optionCompanySpread = {
<section class="w-full max-w-screen overflow-hidden m-auto min-h-screen bg-[#09090B] pb-40"> <section class="w-full max-w-screen overflow-hidden m-auto min-h-screen bg-[#09090B] pb-40">
<div class="flex flex-col w-full max-w-7xl m-auto justify-center items-center"> <div class="flex flex-col w-full max-w-6xl 3xl:max-w-7xl m-auto justify-center items-center">
<div class="text-center mb-10 w-full px-4 sm:px-0 mt-10"> <div class="text-center mb-10 w-full px-4 sm:px-0 mt-10">
<div class="flex flex-col items-start mb-10"> <div class="flex flex-col items-start mb-10">
@ -319,7 +319,6 @@ const optionCompanySpread = {
<main class="w-full"> <main class="w-full">
{#if isLoaded} {#if isLoaded}
<div class="grid gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 md:gap-8"> <div class="grid gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 md:gap-8">
@ -425,10 +424,10 @@ const optionCompanySpread = {
<div class="flex flex-col sm:flex-row items-start sm:items-center justify-between w-full mt-3"> <div class="flex flex-col sm:flex-row items-start sm:items-center justify-between w-full mt-3">
<a href={'https://www.reddit.com/user/'+item?.author} rel="noopener noreferrer" target="_blank" class="text-xs text-white sm:hover:text-blue-400"> <a href={'https://www.reddit.com/user/'+item?.author} rel="noopener noreferrer" target="_blank" class="text-sm sm:text-xs text-white sm:hover:text-blue-400">
Posted by {item?.author} Posted by {item?.author}
</a> </a>
<a href={'https://www.reddit.com'+item?.permalink} rel="noopener noreferrer" target="_blank" class="mt-2 sm:mt-0 text-xs text-white sm:hover:text-blue-400"> <a href={'https://www.reddit.com'+item?.permalink} rel="noopener noreferrer" target="_blank" class="mt-2 sm:mt-0text-sm sm:text-xs text-white sm:hover:text-blue-400">
{formatUtcTimestamp(item?.created_utc)} {formatUtcTimestamp(item?.created_utc)}
<Link class="h-3 w-3 inline-block shrink-0 -mt-1 ml-1" /> <Link class="h-3 w-3 inline-block shrink-0 -mt-1 ml-1" />
</a> </a>

View File

@ -21,6 +21,7 @@ export const config = {
const pages = [ const pages = [
{title: "/"}, {title: "/"},
{title: "/cramer-tracker"}, {title: "/cramer-tracker"},
{title: "/reddit-tracker"},
{title: "/most-shorted-stocks"}, {title: "/most-shorted-stocks"},
{title: "/stocks"}, {title: "/stocks"},
{title: "/etf"}, {title: "/etf"},