2024-07-02 19:38:20 +01:00
|
|
|
<script>
|
|
|
|
import { notifications, getNotifications } from '$lib/notifications.js';
|
2024-07-07 14:58:59 +01:00
|
|
|
import { account } from '$lib/stores/account.js';
|
2024-07-02 20:21:34 +01:00
|
|
|
import { goto } from '$app/navigation';
|
2024-07-03 22:00:32 +01:00
|
|
|
import { page } from '$app/stores';
|
2024-07-02 19:38:20 +01:00
|
|
|
import Notification from '$lib/ui/Notification.svelte';
|
|
|
|
|
2024-07-07 14:58:59 +01:00
|
|
|
if (!$account) goto("/");
|
2024-07-02 20:21:34 +01:00
|
|
|
|
2024-07-02 19:38:20 +01:00
|
|
|
getNotifications();
|
2024-07-07 14:58:59 +01:00
|
|
|
document.addEventListener("scroll", () => {
|
|
|
|
if ($account && $page.url.pathname !== "/notifications") return;
|
2024-07-02 19:38:20 +01:00
|
|
|
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 2048) {
|
|
|
|
getNotifications();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<header>
|
|
|
|
<h1>Notifications</h1>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div class="notifications">
|
|
|
|
{#if $notifications.length === 0}
|
|
|
|
<div class="loading throb">
|
|
|
|
<span>fetching notifications...</span>
|
|
|
|
</div>
|
|
|
|
{:else}
|
|
|
|
{#each $notifications as notif}
|
|
|
|
<Notification data={notif} />
|
|
|
|
{/each}
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
header {
|
|
|
|
width: 100%;
|
|
|
|
height: 64px;
|
|
|
|
margin: 16px 0 8px 0;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
}
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
font-size: 1.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.loading {
|
|
|
|
width: 100%;
|
|
|
|
height: 80vh;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
font-size: 2em;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
</style>
|