finish URL rewrite, remove redundant logged_in state

This commit is contained in:
ari melody 2024-07-07 14:58:59 +01:00
parent a3fdd0007c
commit 4d771d8ebd
Signed by: ari
GPG key ID: CF99829C92678188
9 changed files with 20 additions and 27 deletions

View file

@ -3,7 +3,7 @@
import * as api from '$lib/api.js';
import { server } from '$lib/client/server.js';
import { app } from '$lib/client/app.js';
import { account, logged_in } from '$lib/stores/account.js';
import { account } from '$lib/stores/account.js';
import { parseAccount } from '$lib/account.js';
import { unread_notif_count, last_read_notif_id } from '$lib/notifications.js';
@ -17,7 +17,6 @@
async function init() {
if (!$app || !$app.token) {
account.set(false);
logged_in.set(false);
return;
}
@ -26,7 +25,6 @@
if (!data) return;
account.set(parseAccount(data));
logged_in.set(true);
console.log(`Logged in as @${$account.username}@${$account.host}`);
// spin up async task to fetch notifications

View file

@ -1,6 +1,5 @@
<script>
import { page } from '$app/stores';
import { get } from 'svelte/store';
import { account } from '$lib/stores/account.js';
import { timeline, getTimeline } from '$lib/timeline.js';
@ -13,7 +12,7 @@
});
document.addEventListener("scroll", () => {
if (get(logged_in) && get(page).url.pathname !== "/") return;
if ($account && $page.url.pathname !== "/") return;
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 2048) {
getTimeline();
}

View file

@ -4,7 +4,7 @@
import { app } from '$lib/client/app.js';
import { parsePost } from '$lib/post.js';
import { goto, afterNavigate } from '$app/navigation';
import { base as previous_page } from '$app/paths'
import { base } from '$app/paths'
import Post from '$lib/ui/post/Post.svelte';
import Button from '$lib/ui/Button.svelte';
@ -13,6 +13,7 @@
let post;
let error = false;
let previous_page = base;
if (($server && $server.host === data.server_host) && $app) {
post = fetchPost(data.post_id, $app.token);

View file

@ -7,7 +7,7 @@
import { goto } from '$app/navigation';
import { error } from '@sveltejs/kit';
import { unread_notif_count, last_read_notif_id } from '$lib/notifications.js';
import { logged_in, account } from '$lib/stores/account.js';
import { account } from '$lib/stores/account.js';
export let data;
@ -30,7 +30,6 @@
if (!data) return goto("/");
account.set(parseAccount(data));
logged_in.set(true);
console.log(`Logged in as @${get(account).username}@${get(account).host}`);
// spin up async task to fetch notifications

View file

@ -1,16 +1,15 @@
<script>
import { notifications, getNotifications } from '$lib/notifications.js';
import { logged_in } from '$lib/stores/account.js';
import { account } from '$lib/stores/account.js';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { get } from 'svelte/store';
import Notification from '$lib/ui/Notification.svelte';
if (!get(logged_in)) goto("/");
if (!$account) goto("/");
getNotifications();
document.addEventListener("scroll", event => {
if (get(logged_in) && get(page).url.pathname !== "/notifications") return;
document.addEventListener("scroll", () => {
if ($account && $page.url.pathname !== "/notifications") return;
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 2048) {
getNotifications();
}