Fix badge showing on current page

This commit is contained in:
Jon Staab
2026-02-09 17:11:03 -08:00
parent f80aba33f1
commit 028c3ba92b
2 changed files with 3 additions and 12 deletions
+2 -10
View File
@@ -1,6 +1,5 @@
<script lang="ts">
import type {Snippet} from "svelte"
import {page} from "$app/stores"
import {goto} from "$app/navigation"
import {splitAt} from "@welshman/lib"
import {userProfile, shouldUnwrap} from "@welshman/app"
@@ -21,7 +20,6 @@
import PrimaryNavItemSpace from "@app/components/PrimaryNavItemSpace.svelte"
import {userSpaceUrls, PLATFORM_RELAYS, PLATFORM_LOGO} from "@app/core/state"
import {pushModal} from "@app/util/modal"
import {makeSpacePath} from "@app/util/routes"
import {notifications} from "@app/util/notifications"
type Props = {
@@ -36,20 +34,14 @@
const openChat = () => ($shouldUnwrap ? goto("/chat") : pushModal(ChatEnable, {next: "/chat"}))
const hasNotification = (url: string) => {
const path = makeSpacePath(url)
return !$page.url.pathname.startsWith(path) && $notifications.has(path)
}
let windowHeight = $state(0)
const itemHeight = 56
const navPadding = 8 * itemHeight
const itemLimit = $derived((windowHeight - navPadding) / itemHeight)
const [primarySpaceUrls, secondarySpaceUrls] = $derived(splitAt(itemLimit, $userSpaceUrls))
const anySpaceNotifications = $derived($userSpaceUrls.some(hasNotification))
const otherSpaceNotifications = $derived(secondarySpaceUrls.some(hasNotification))
const anySpaceNotifications = $derived($userSpaceUrls.some(p => $notifications.has(p)))
const otherSpaceNotifications = $derived(secondarySpaceUrls.some(p => $notifications.has(p)))
</script>
<svelte:window bind:innerHeight={windowHeight} />
+1 -2
View File
@@ -25,7 +25,6 @@ import {
spec,
first,
identity,
remove,
now,
maybe,
throttle,
@@ -182,7 +181,7 @@ export const allNotifications = derived(
)
export const notifications = derived([page, allNotifications], ([$page, $allNotifications]) => {
return new Set(remove($page.url.pathname, [...$allNotifications]))
return new Set([...$allNotifications].filter(p => $page.url.pathname.startsWith(p)))
})
export const onNotification = call(() => {