From bf91187c1fbb751d428bb14a25f659492d106a3f Mon Sep 17 00:00:00 2001 From: Ren Amamiya <123083837+reyamir@users.noreply.github.com> Date: Sun, 27 Aug 2023 14:46:48 +0700 Subject: [PATCH] update notification screen --- src/app.tsx | 6 +-- src/app/lodge/components/base/list.tsx | 3 -- .../components/content.tsx | 0 .../components/mention.tsx | 4 +- .../components/reaction.tsx | 4 +- .../components/repost.tsx | 4 +- .../components/simpleNote.tsx | 0 .../components/user.tsx | 0 src/app/{lodge => notifications}/index.tsx | 30 +++++--------- src/shared/accounts/active.tsx | 40 +++++++++++++++++++ src/shared/navigation.tsx | 4 +- src/utils/notification.ts | 4 +- 12 files changed, 62 insertions(+), 37 deletions(-) delete mode 100644 src/app/lodge/components/base/list.tsx rename src/app/{lodge => notifications}/components/content.tsx (100%) rename src/app/{lodge => notifications}/components/mention.tsx (89%) rename src/app/{lodge => notifications}/components/reaction.tsx (87%) rename src/app/{lodge => notifications}/components/repost.tsx (89%) rename src/app/{lodge => notifications}/components/simpleNote.tsx (100%) rename src/app/{lodge => notifications}/components/user.tsx (100%) rename src/app/{lodge => notifications}/index.tsx (72%) diff --git a/src/app.tsx b/src/app.tsx index d6049276..0285b39d 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -70,10 +70,10 @@ const router = createBrowserRouter([ }, }, { - path: 'lodge', + path: 'notifications', async lazy() { - const { LodgeScreen } = await import('@app/lodge'); - return { Component: LodgeScreen }; + const { NotificationScreen } = await import('@app/notifications'); + return { Component: NotificationScreen }; }, }, ], diff --git a/src/app/lodge/components/base/list.tsx b/src/app/lodge/components/base/list.tsx deleted file mode 100644 index 04d7b94e..00000000 --- a/src/app/lodge/components/base/list.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export function BaseList() { - return
; -} diff --git a/src/app/lodge/components/content.tsx b/src/app/notifications/components/content.tsx similarity index 100% rename from src/app/lodge/components/content.tsx rename to src/app/notifications/components/content.tsx diff --git a/src/app/lodge/components/mention.tsx b/src/app/notifications/components/mention.tsx similarity index 89% rename from src/app/lodge/components/mention.tsx rename to src/app/notifications/components/mention.tsx index 672acbf9..c527a760 100644 --- a/src/app/lodge/components/mention.tsx +++ b/src/app/notifications/components/mention.tsx @@ -1,8 +1,8 @@ import { NDKEvent } from '@nostr-dev-kit/ndk'; import { useMemo } from 'react'; -import { NotiContent } from '@app/lodge/components/content'; -import { NotiUser } from '@app/lodge/components/user'; +import { NotiContent } from '@app/notifications/components/content'; +import { NotiUser } from '@app/notifications/components/user'; import { formatCreatedAt } from '@utils/createdAt'; import { parser } from '@utils/parser'; diff --git a/src/app/lodge/components/reaction.tsx b/src/app/notifications/components/reaction.tsx similarity index 87% rename from src/app/lodge/components/reaction.tsx rename to src/app/notifications/components/reaction.tsx index 04e80391..7c0e1749 100644 --- a/src/app/lodge/components/reaction.tsx +++ b/src/app/notifications/components/reaction.tsx @@ -1,7 +1,7 @@ import { NDKEvent } from '@nostr-dev-kit/ndk'; -import { SimpleNote } from '@app/lodge/components/simpleNote'; -import { NotiUser } from '@app/lodge/components/user'; +import { SimpleNote } from '@app/notifications/components/simpleNote'; +import { NotiUser } from '@app/notifications/components/user'; import { formatCreatedAt } from '@utils/createdAt'; diff --git a/src/app/lodge/components/repost.tsx b/src/app/notifications/components/repost.tsx similarity index 89% rename from src/app/lodge/components/repost.tsx rename to src/app/notifications/components/repost.tsx index 21e6f807..d0e1a77b 100644 --- a/src/app/lodge/components/repost.tsx +++ b/src/app/notifications/components/repost.tsx @@ -1,7 +1,7 @@ import { NDKEvent } from '@nostr-dev-kit/ndk'; -import { SimpleNote } from '@app/lodge/components/simpleNote'; -import { NotiUser } from '@app/lodge/components/user'; +import { SimpleNote } from '@app/notifications/components/simpleNote'; +import { NotiUser } from '@app/notifications/components/user'; import { useStorage } from '@libs/storage/provider'; diff --git a/src/app/lodge/components/simpleNote.tsx b/src/app/notifications/components/simpleNote.tsx similarity index 100% rename from src/app/lodge/components/simpleNote.tsx rename to src/app/notifications/components/simpleNote.tsx diff --git a/src/app/lodge/components/user.tsx b/src/app/notifications/components/user.tsx similarity index 100% rename from src/app/lodge/components/user.tsx rename to src/app/notifications/components/user.tsx diff --git a/src/app/lodge/index.tsx b/src/app/notifications/index.tsx similarity index 72% rename from src/app/lodge/index.tsx rename to src/app/notifications/index.tsx index 1f965f47..3402eb3e 100644 --- a/src/app/lodge/index.tsx +++ b/src/app/notifications/index.tsx @@ -1,10 +1,10 @@ -import { NDKEvent, NDKFilter } from '@nostr-dev-kit/ndk'; +import { NDKEvent } from '@nostr-dev-kit/ndk'; import { useQuery } from '@tanstack/react-query'; -import { useCallback, useEffect } from 'react'; +import { useCallback } from 'react'; -import { NotiMention } from '@app/lodge/components/mention'; -import { NotiReaction } from '@app/lodge/components/reaction'; -import { NotiRepost } from '@app/lodge/components/repost'; +import { NotiMention } from '@app/notifications/components/mention'; +import { NotiReaction } from '@app/notifications/components/reaction'; +import { NotiRepost } from '@app/notifications/components/repost'; import { useStorage } from '@libs/storage/provider'; @@ -13,11 +13,11 @@ import { TitleBar } from '@shared/titleBar'; import { useNostr } from '@utils/hooks/useNostr'; -export function LodgeScreen() { +export function NotificationScreen() { const { db } = useStorage(); - const { sub, fetchActivities } = useNostr(); + const { fetchActivities } = useNostr(); const { status, data } = useQuery( - ['lodge', db.account.pubkey], + ['notifications', db.account.pubkey], async () => { return await fetchActivities(); }, @@ -40,22 +40,10 @@ export function LodgeScreen() { [data] ); - useEffect(() => { - const filter: NDKFilter = { - '#p': [db.account.pubkey], - kinds: [1, 3, 6, 7, 9735], - since: db.account.last_login_at ?? Math.floor(Date.now() / 1000), - }; - - sub(filter, async (event) => { - console.log('[notify] new noti', event.id); - }); - }, []); - return (