This commit is contained in:
MuslemRahimi 2024-06-12 23:43:47 +02:00
parent 304b6e1a55
commit dd4eb6abf7
2 changed files with 9 additions and 20 deletions

View File

@ -224,10 +224,13 @@ $: {
{:else}
<h2 class="mt-10 mb-5 flex justify-center items-center text-3xl font-bold text-slate-700 m-auto">
No data available
<svg class="w-10 sm:w-12 inline-block" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#334155" d="M18.68 12.32a4.49 4.49 0 0 0-6.36.01a4.49 4.49 0 0 0 0 6.36a4.508 4.508 0 0 0 5.57.63L21 22.39L22.39 21l-3.09-3.11c1.13-1.77.87-4.09-.62-5.57m-1.41 4.95c-.98.98-2.56.97-3.54 0c-.97-.98-.97-2.56.01-3.54c.97-.97 2.55-.97 3.53 0c.97.98.97 2.56 0 3.54M10.9 20.1a6.527 6.527 0 0 1-1.48-2.32C6.27 17.25 4 15.76 4 14v3c0 2.21 3.58 4 8 4c-.4-.26-.77-.56-1.1-.9M4 9v3c0 1.68 2.07 3.12 5 3.7v-.2c0-.93.2-1.85.58-2.69C6.34 12.3 4 10.79 4 9m8-6C7.58 3 4 4.79 4 7c0 2 3 3.68 6.85 4h.05c1.2-1.26 2.86-2 4.6-2c.91 0 1.81.19 2.64.56A3.215 3.215 0 0 0 20 7c0-2.21-3.58-4-8-4Z"/></svg>
</h2>
<div class="flex justify-center items-center h-80">
<div class="relative">
<label class="bg-[#202020] rounded-xl h-14 w-14 flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">
<span class="loading loading-spinner loading-md"></span>
</label>
</div>
</div>
{/if}
{:else}

View File

@ -1,18 +1,5 @@
// lib/workers/test.ts
async function loadTwitchStatus(fastifyURL:string,) {
// make the GET request to the endpoint
const response = await fetch(fastifyURL+'/get-twitch-status', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
});
const output = (await response.json())?.items;
return output;
}
async function loadSearchData(apiURL:string) {
try {
@ -58,17 +45,16 @@ async function loadNotifications(fastifyURL:string, userId:string) {
//console.log(ticker, apiURL);
try {
const [searchBarData, notificationList, twitchStatus] = await Promise.all([
const [searchBarData, notificationList] = await Promise.all([
loadSearchData(apiURL),
loadNotifications(fastifyURL, userId),
loadTwitchStatus(fastifyURL),
]);
const unreadNotificationList = notificationList?.filter(item => item?.readed === false);
const hasUnreadElement = notificationList?.some(item => item?.readed === false);
const numberOfUnreadNotification = notificationList?.filter(item => item?.readed === false)?.length;
const output = {searchBarData, notificationList, hasUnreadElement, numberOfUnreadNotification, unreadNotificationList, twitchStatus}
const output = {searchBarData, notificationList, hasUnreadElement, numberOfUnreadNotification, unreadNotificationList}
postMessage({ message: 'success', output});
} catch(e) {