From 2f62b3d934c77348f409d550965cf15b0ff5278d Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Thu, 12 Dec 2024 23:47:17 +0100 Subject: [PATCH] add modal for app && remove LTD --- src/lib/components/AppInstalled.svelte | 127 ++++++++++++++++++++ src/lib/store.ts | 1 + src/routes/+page.svelte | 87 ++++++-------- src/routes/pricing/+page.svelte | 158 +------------------------ 4 files changed, 164 insertions(+), 209 deletions(-) create mode 100644 src/lib/components/AppInstalled.svelte diff --git a/src/lib/components/AppInstalled.svelte b/src/lib/components/AppInstalled.svelte new file mode 100644 index 00000000..a1b3ae56 --- /dev/null +++ b/src/lib/components/AppInstalled.svelte @@ -0,0 +1,127 @@ + + + + + + +
+ + +
+

+ Get the app for a better experience. +

+ +
+ + +
+
+
+ + + + + + + + + diff --git a/src/lib/store.ts b/src/lib/store.ts index 015446a9..2cc5b6fb 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -50,6 +50,7 @@ export const shouldUpdatePriceChart = writable(false); export const coolMode = writable(false); export const timeFrame =writable("Max"); +export const closedPWA = writable(false); export const executiveClicked = writable(false); export const secFilingsClicked = writable(false); diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index b760b75d..05e9008d 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -9,6 +9,7 @@ import HoverStockChart from "$lib/components/HoverStockChart.svelte"; import { screenWidth, numberOfUnreadNotification } from "$lib/store"; import { compareTimes, formatTime, isPWAInstalled } from "$lib/utils"; + import { closedPWA } from "$lib/store"; export let data; let optionsMode = "premium"; @@ -41,10 +42,38 @@ } let Feedback; let pwaInstalled = false; + let AppInstalled = null; + + function getClosedPWA() { + const item = localStorage.getItem("closePWA"); + if (!item) return null; + + const { value, expires } = JSON.parse(item); + if (new Date() > new Date(expires)) { + localStorage.removeItem("closePWA"); // Remove expired item + return null; + } + return value; + } + onMount(async () => { pwaInstalled = isPWAInstalled(); + + if (!pwaInstalled) { + try { + $closedPWA = getClosedPWA(); + + if (!$closedPWA) { + // Dynamically import the AppInstalled component + AppInstalled = (await import("$lib/components/AppInstalled.svelte")) + .default; + } + } catch (e) { + console.error("Error loading AppInstalled component:", e); + } + } + Feedback = (await import("$lib/components/Feedback.svelte")).default; - console.log(pwaInstalled); }); $: charNumber = $screenWidth < 640 ? 20 : 15; @@ -90,59 +119,9 @@
- + {#if AppInstalled && !$closedPWA} + + {/if} - - - -
-
- - Limited Offer - -
- -
- Lifetime tier -

Lifetime

-
- -
-
- $399 -
-
- -
    -
  1. - - Everything in Pro Tier. -
  2. -
  3. - - Pay Once and use forever. -
  4. -
  5. - - - If you ❤️ Stocknear and want to support us, this is the best way. -
  6. -
- -
-
- + Unlimited feature updates -
- - -
- -