From 42f0ff2ff820f71a35ad5fc28d91796b69c719c5 Mon Sep 17 00:00:00 2001 From: ari melody Date: Tue, 2 Jul 2024 12:36:26 +0100 Subject: [PATCH] fixed navigation not reflecting current route --- src/lib/client/client.js | 1 - src/lib/ui/Navigation.svelte | 40 ++++++++++++++++++++++++++---------- src/routes/+layout.svelte | 13 +++++++++--- src/routes/+page.js | 4 ++++ 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/lib/client/client.js b/src/lib/client/client.js index e540622..44e7b53 100644 --- a/src/lib/client/client.js +++ b/src/lib/client/client.js @@ -90,7 +90,6 @@ export class Client { } const user = await api.parseUser(data); console.log(`Logged in as @${user.username}@${user.host}`); - console.log(`You have ${data.source.follow_request_count} follow request${data.source.follow_request_count === 1 ? '' : 's'}!`); return user; } diff --git a/src/lib/ui/Navigation.svelte b/src/lib/ui/Navigation.svelte index 607a14d..ef16b70 100644 --- a/src/lib/ui/Navigation.svelte +++ b/src/lib/ui/Navigation.svelte @@ -7,6 +7,7 @@ import { getTimeline } from '$lib/timeline.js'; import { goto } from '$app/navigation'; import { get } from 'svelte/store'; + import { onMount } from 'svelte'; import TimelineIcon from '../../img/icons/timeline.svg'; import NotificationsIcon from '../../img/icons/notifications.svg'; @@ -20,21 +21,33 @@ import SettingsIcon from '../../img/icons/settings.svg'; import LogoutIcon from '../../img/icons/logout.svg'; + export let path; + const VERSION = APP_VERSION; let notification_count = 0; if (notification_count > 99) notification_count = "99+"; - function goTimeline() { - if (location.pathname === "/") { - getTimeline(true); - window.scrollTo({ - top: 0, - behavior: "smooth" - }); - return; + function handle_btn(name) { + let route; + switch (name) { + case "timeline": + route = "/"; + break; + case "notifcations": + case "explore": + case "lists": + case "favourites": + case "bookmarks": + case "hashtags": + return; } - goto("/"); + if (!route) return; + window.scrollTo({ + top: 0, + behavior: "smooth" + }); + goto(route); } async function log_out() { @@ -52,13 +65,18 @@