diff --git a/ROADMAP.md b/ROADMAP.md index b57635ca..935038a4 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,7 +1,5 @@ # Current -- [ ] Fix notifications, separate into mentions/replies and other -- [ ] Wait for an auth challenge based on relay document to avoid missing first few REQs - [ ] Extract libraries - Cursor - parseContent diff --git a/src/app/Routes.svelte b/src/app/Routes.svelte index 759b637d..1c33f726 100644 --- a/src/app/Routes.svelte +++ b/src/app/Routes.svelte @@ -31,6 +31,7 @@ {#if ready}
+ diff --git a/src/app/views/Notification.svelte b/src/app/views/Notification.svelte index 8ca0be0e..0fc8975b 100644 --- a/src/app/views/Notification.svelte +++ b/src/app/views/Notification.svelte @@ -35,7 +35,7 @@ if (likes.length === notifications.length) return "liked" if (zaps.length === notifications.length) return "zapped" - return "interacted with" + return "reacted to" }) diff --git a/src/app/views/Notifications.svelte b/src/app/views/Notifications.svelte index 3541c753..55c580a5 100644 --- a/src/app/views/Notifications.svelte +++ b/src/app/views/Notifications.svelte @@ -3,20 +3,25 @@ import {pluck, reverse, max, last, sortBy} from "ramda" import {onMount} from "svelte" import {fly} from "svelte/transition" + import {navigate} from "svelte-routing" import {now, timedelta, createScroller} from "src/util/misc" import {findReplyId} from "src/util/nostr" import Spinner from "src/partials/Spinner.svelte" + import Tabs from "src/partials/Tabs.svelte" import Content from "src/partials/Content.svelte" import Notification from "src/app/views/Notification.svelte" import {watch} from "src/agent/db" import user from "src/agent/user" import {userEvents} from "src/agent/db" + const {lastChecked} = user + const tabs = ["Mentions & Replies", "Reactions"] + + export let activeTab = tabs[0] + let limit = 0 let events = null - const {lastChecked} = user - const prevChecked = $lastChecked.notifications || 0 const updateLastChecked = throttle(30_000, () => user.setLastChecked("notifications", now() + 30)) const notifications = watch("notifications", t => { @@ -35,7 +40,17 @@ $: events = $notifications .slice(0, limit) .map(e => [e, findReplyId(e)]) - .filter(([e, ref]) => userEvents.get(ref)?.kind === 1) + .filter(([e, ref]) => { + if (userEvents.get(ref)?.kind !== 1) { + return false + } + + if (activeTab === tabs[0]) { + return [1].includes(e.kind) + } else { + return [7, 9735].includes(e.kind) + } + }) .reduce((r, [e, ref]) => { const prev = last(r) const prevTimestamp = pluck("created_at", prev?.notifications || []).reduce(max, 0) @@ -54,6 +69,8 @@ return r }, []) + const setActiveTab = tab => navigate(`/notifications/${tab}`) + onMount(() => { document.title = "Notifications" @@ -65,6 +82,7 @@ {#if events} + {#each events as event (event.key)}