2024-06-29 17:27:46 +01:00
|
|
|
<script>
|
2024-06-29 19:52:52 +01:00
|
|
|
import '$lib/app.css';
|
2024-07-03 22:00:32 +01:00
|
|
|
import * as api from '$lib/api.js';
|
|
|
|
import { server } from '$lib/client/server.js';
|
|
|
|
import { app } from '$lib/client/app.js';
|
2024-07-07 14:58:59 +01:00
|
|
|
import { account } from '$lib/stores/account.js';
|
2024-07-03 22:00:32 +01:00
|
|
|
import { parseAccount } from '$lib/account.js';
|
|
|
|
import { unread_notif_count, last_read_notif_id } from '$lib/notifications.js';
|
2025-07-13 18:49:49 +01:00
|
|
|
import Lang from '$lib/lang';
|
2024-07-03 22:00:32 +01:00
|
|
|
|
2024-06-29 17:27:46 +01:00
|
|
|
import Navigation from '$lib/ui/Navigation.svelte';
|
2024-07-04 16:55:57 +01:00
|
|
|
import Modal from '@cf/ui/Modal.svelte';
|
|
|
|
import Composer from '@cf/ui/Composer.svelte';
|
2024-06-29 17:27:46 +01:00
|
|
|
import Widgets from '$lib/ui/Widgets.svelte';
|
2024-07-02 12:36:26 +01:00
|
|
|
|
2025-07-13 18:49:49 +01:00
|
|
|
const lang = Lang('en_GB');
|
|
|
|
|
2024-07-04 16:55:57 +01:00
|
|
|
let show_composer = false;
|
|
|
|
|
2024-07-03 22:00:32 +01:00
|
|
|
async function init() {
|
2024-07-07 14:33:28 +01:00
|
|
|
if (!$app || !$app.token) {
|
2024-07-03 22:00:32 +01:00
|
|
|
account.set(false);
|
|
|
|
return;
|
2024-07-01 03:41:02 +01:00
|
|
|
}
|
|
|
|
|
2024-07-03 22:00:32 +01:00
|
|
|
// logged in- attempt to retrieve using token
|
2024-07-07 14:33:28 +01:00
|
|
|
const data = await api.verifyCredentials($server.host, $app.token);
|
2024-07-03 22:00:32 +01:00
|
|
|
if (!data) return;
|
|
|
|
|
|
|
|
account.set(parseAccount(data));
|
2025-07-13 19:04:50 +01:00
|
|
|
console.log(`Logged in as ${$account.fqn}`);
|
2024-07-02 20:21:34 +01:00
|
|
|
|
2024-07-03 22:00:32 +01:00
|
|
|
// spin up async task to fetch notifications
|
|
|
|
const notif_data = await api.getNotifications(
|
2024-07-07 14:33:28 +01:00
|
|
|
$server.host,
|
|
|
|
$app.token,
|
|
|
|
$last_read_notif_id
|
2024-07-03 22:00:32 +01:00
|
|
|
);
|
2024-07-02 19:38:20 +01:00
|
|
|
|
2024-07-03 22:00:32 +01:00
|
|
|
if (!notif_data) return;
|
2024-07-02 19:38:20 +01:00
|
|
|
|
2024-07-03 22:00:32 +01:00
|
|
|
unread_notif_count.set(notif_data.length);
|
|
|
|
};
|
2024-06-29 17:27:46 +01:00
|
|
|
</script>
|
|
|
|
|
2024-06-30 17:37:19 +01:00
|
|
|
<div id="app">
|
2024-06-29 17:27:46 +01:00
|
|
|
<header>
|
2024-07-04 16:55:57 +01:00
|
|
|
<Navigation on:compose={() => show_composer = true} />
|
2024-06-29 17:27:46 +01:00
|
|
|
</header>
|
|
|
|
|
|
|
|
<main>
|
2024-07-03 22:00:32 +01:00
|
|
|
{#await init()}
|
2024-06-30 21:39:37 +01:00
|
|
|
<div class="loading throb">
|
2025-07-13 18:49:49 +01:00
|
|
|
<span>{lang.string('loading')}</span>
|
2024-06-30 21:39:37 +01:00
|
|
|
</div>
|
|
|
|
{:then}
|
|
|
|
<slot></slot>
|
|
|
|
{/await}
|
2024-06-29 17:27:46 +01:00
|
|
|
</main>
|
|
|
|
|
|
|
|
<div id="widgets">
|
|
|
|
<Widgets />
|
|
|
|
</div>
|
|
|
|
|
2024-07-04 16:55:57 +01:00
|
|
|
<Modal bind:visible={show_composer}>
|
2024-07-05 14:51:32 +01:00
|
|
|
<Composer on:compose_finished={() => show_composer = false }/>
|
2024-07-04 16:55:57 +01:00
|
|
|
</Modal>
|
2024-06-29 17:27:46 +01:00
|
|
|
</div>
|
2024-07-01 03:41:02 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.loading {
|
|
|
|
width: 100%;
|
|
|
|
height: 100vh;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
font-size: 2em;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
</style>
|