diff --git a/src/components/MapLoading.svelte b/src/components/MapLoading.svelte deleted file mode 100644 index 66b8e081..00000000 --- a/src/components/MapLoading.svelte +++ /dev/null @@ -1,44 +0,0 @@ - - -{#if type === 'main'} -
-
-
-
- {#if typeof window !== 'undefined'} -
- -
- {/if} -

- {message} -

-
-
-
-
-{:else if type === 'embed'} -
-
- -

Rendering map...

-
-
-{/if} diff --git a/src/components/MapLoadingEmbed.svelte b/src/components/MapLoadingEmbed.svelte new file mode 100644 index 00000000..368c37e0 --- /dev/null +++ b/src/components/MapLoadingEmbed.svelte @@ -0,0 +1,14 @@ + + +
+
+ +

Loading map...

+
+
diff --git a/src/components/MapLoadingMain.svelte b/src/components/MapLoadingMain.svelte new file mode 100644 index 00000000..88702d40 --- /dev/null +++ b/src/components/MapLoadingMain.svelte @@ -0,0 +1,30 @@ + + +{#if progress !== undefined} +
+

Loading map...

+ +
+ +
+{/if} diff --git a/src/lib/comp.ts b/src/lib/comp.ts index c6b4791f..878e7758 100644 --- a/src/lib/comp.ts +++ b/src/lib/comp.ts @@ -30,7 +30,8 @@ export { default as LeaderboardItem } from '../components/LeaderboardItem.svelte export { default as LeaderboardSkeleton } from '../components/LeaderboardSkeleton.svelte'; export { default as LoadingSpinner } from '../components/LoadingSpinner.svelte'; export { default as LoadingSplash } from '../components/LoadingSplash.svelte'; -export { default as MapLoading } from '../components/MapLoading.svelte'; +export { default as MapLoadingEmbed } from '../components/MapLoadingEmbed.svelte'; +export { default as MapLoadingMain } from '../components/MapLoadingMain.svelte'; export { default as MerchantButton } from '../components/MerchantButton.svelte'; export { default as MerchantEvent } from '../components/MerchantEvent.svelte'; export { default as MerchantLink } from '../components/MerchantLink.svelte'; diff --git a/src/lib/store.ts b/src/lib/store.ts index 783d5cf3..3a3ffd1e 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -61,7 +61,6 @@ export const reportError = writable(''); export const syncStatus: Writable = writable(); export const mapUpdates = writable(false); -export const mapLoading = writable('Loading map...'); export const excludeLeader = readable([ 17085479, 2104834, 9451067, 616463, 1722488, 81735, 18545877, 232801, 19880430, 1778799 diff --git a/src/lib/sync/elements.ts b/src/lib/sync/elements.ts index 7b3815ec..d10d6d39 100644 --- a/src/lib/sync/elements.ts +++ b/src/lib/sync/elements.ts @@ -1,4 +1,4 @@ -import { elementError, elements, elementsSyncCount, mapLoading, mapUpdates } from '$lib/store'; +import { elementError, elements, elementsSyncCount, mapUpdates } from '$lib/store'; import type { Element } from '$lib/types'; import axios from 'axios'; import axiosRetry from 'axios-retry'; @@ -10,8 +10,6 @@ axiosRetry(axios, { retries: 3 }); const limit = 5000; export const elementsSync = async () => { - mapLoading.set('Checking local cache...'); - // clear v1 table if present await localforage .getItem('elements') @@ -72,8 +70,6 @@ export const elementsSync = async () => { let responseCount; let elementsData: Element[] = []; - mapLoading.set('Fetching elements...'); - do { try { const response = await axios.get( @@ -104,17 +100,14 @@ export const elementsSync = async () => { } while (responseCount === limit); if (elementsData.length) { - mapLoading.set('Storing data...'); // set response to local localforage .setItem('elements_v3', elementsData) .then(function () { - mapLoading.set('Initial sync complete!'); // set response to store elements.set(elementsData); }) .catch(function (err) { - mapLoading.set('Map loading complete!'); elements.set(elementsData); elementError.set( 'Could not store elements locally, please try again or contact BTC Map.' @@ -123,8 +116,6 @@ export const elementsSync = async () => { }); } } else { - mapLoading.set('Local cache found!'); - // add to sync count to only show data refresh after initial load const count = get(elementsSyncCount); elementsSyncCount.set(count + 1); @@ -139,8 +130,6 @@ export const elementsSync = async () => { let elementsData = value; let useCachedData = false; - mapLoading.set('Fetching new elements...'); - do { try { const response = await axios.get( @@ -169,7 +158,6 @@ export const elementsSync = async () => { elementsData.push(element); }); } else { - mapLoading.set('Map loading complete!'); // set cached elements to store elements.set(value); useCachedData = true; @@ -190,12 +178,9 @@ export const elementsSync = async () => { if (!useCachedData) { // set updated elements locally - mapLoading.set('Storing data...'); - localforage .setItem('elements_v3', elementsData) .then(function () { - mapLoading.set('Map loading complete!'); // set updated elements to store elements.set(elementsData); @@ -230,8 +215,6 @@ export const elementsSync = async () => { let responseCount; let elementsData: Element[] = []; - mapLoading.set('Fetching elements...'); - do { try { const response = await axios.get( @@ -262,7 +245,6 @@ export const elementsSync = async () => { } while (responseCount === limit); if (elementsData.length) { - mapLoading.set('Map loading complete!'); // set response to store elements.set(elementsData); } diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 10756eb5..e6b6fc93 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -4,8 +4,6 @@ import type { Chart } from 'chart.js'; import { get } from 'svelte/store'; export const errToast = (m: string) => { - toast.pop(); - toast.push(m, { theme: { '--toastBarBackground': '#DF3C3C' @@ -14,8 +12,6 @@ export const errToast = (m: string) => { }; export const warningToast = (m: string) => { - toast.pop(); - toast.push(m, { theme: { '--toastBarBackground': '#FACA15' @@ -25,8 +21,6 @@ export const warningToast = (m: string) => { }; export const successToast = (m: string) => { - toast.pop(); - toast.push(m, { theme: { '--toastBarBackground': '#22C55E' diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index e8697fb9..64d4c4ab 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,6 +1,6 @@ - - - BTC Map - Community Map - - - - - -

Community Map

- -{#if $areas && $areas.length && $reports && $reports.length} - -{:else} - -{/if} diff --git a/src/routes/communities/map/+page.svelte b/src/routes/communities/map/+page.svelte index 8a6e8836..134edcda 100644 --- a/src/routes/communities/map/+page.svelte +++ b/src/routes/communities/map/+page.svelte @@ -1,7 +1,7 @@ + + BTC Map - Community Map + + + + +
- {#if !mapLoaded} - - {/if} +

Community Map

+ +
diff --git a/src/routes/community/[area]/+page.svelte b/src/routes/community/[area]/+page.svelte index ca15f02d..c66c6119 100644 --- a/src/routes/community/[area]/+page.svelte +++ b/src/routes/community/[area]/+page.svelte @@ -8,7 +8,7 @@ Header, InfoTooltip, LatestTagger, - MapLoading, + MapLoadingEmbed, OpenTicket, OrgBadge, ProfileStat, @@ -865,8 +865,7 @@ class="z-10 h-[300px] rounded-b-3xl border border-statBorder !bg-teal text-left dark:!bg-[#202f33] md:h-[600px]" /> {#if !mapLoaded} - {/if} diff --git a/src/routes/map/+layout.svelte b/src/routes/map/+layout.svelte deleted file mode 100644 index 3dfb3d80..00000000 --- a/src/routes/map/+layout.svelte +++ /dev/null @@ -1,23 +0,0 @@ - - - - BTC Map - - - - - -

Map

- -{#if $elements && $elements.length} - -{:else} - -{/if} diff --git a/src/routes/map/+page.svelte b/src/routes/map/+page.svelte index ed33819d..3240b781 100644 --- a/src/routes/map/+page.svelte +++ b/src/routes/map/+page.svelte @@ -1,7 +1,7 @@ + + BTC Map + + + + +
- {#if !mapLoaded} - - {/if} +

Map

+ +