diff --git a/package.json b/package.json index 9b12f64a..f096c342 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "lume", + "description": "the communication app", "private": true, "version": "1.2.0", "scripts": { diff --git a/src/app.tsx b/src/app.tsx index d42e0247..d6049276 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -70,10 +70,10 @@ const router = createBrowserRouter([ }, }, { - path: 'notifications', + path: 'lodge', async lazy() { - const { NotificationScreen } = await import('@app/notification'); - return { Component: NotificationScreen }; + const { LodgeScreen } = await import('@app/lodge'); + return { Component: LodgeScreen }; }, }, ], diff --git a/src/app/lodge/components/base/list.tsx b/src/app/lodge/components/base/list.tsx new file mode 100644 index 00000000..04d7b94e --- /dev/null +++ b/src/app/lodge/components/base/list.tsx @@ -0,0 +1,3 @@ +export function BaseList() { + return
; +} diff --git a/src/app/notification/components/content.tsx b/src/app/lodge/components/content.tsx similarity index 100% rename from src/app/notification/components/content.tsx rename to src/app/lodge/components/content.tsx diff --git a/src/app/lodge/components/mention.tsx b/src/app/lodge/components/mention.tsx new file mode 100644 index 00000000..672acbf9 --- /dev/null +++ b/src/app/lodge/components/mention.tsx @@ -0,0 +1,32 @@ +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 { formatCreatedAt } from '@utils/createdAt'; +import { parser } from '@utils/parser'; + +export function NotiMention({ event }: { event: NDKEvent }) { + const createdAt = formatCreatedAt(event.created_at); + const content = useMemo(() => parser(event), [event]); + + return ( +
+
+
+
+ +

has reply you post 路 {createdAt}

+
+
+
+
+
+ +
+
+
+
+ ); +} diff --git a/src/app/lodge/components/reaction.tsx b/src/app/lodge/components/reaction.tsx new file mode 100644 index 00000000..04e80391 --- /dev/null +++ b/src/app/lodge/components/reaction.tsx @@ -0,0 +1,30 @@ +import { NDKEvent } from '@nostr-dev-kit/ndk'; + +import { SimpleNote } from '@app/lodge/components/simpleNote'; +import { NotiUser } from '@app/lodge/components/user'; + +import { formatCreatedAt } from '@utils/createdAt'; + +export function NotiReaction({ event }: { event: NDKEvent }) { + const root = event.tags.find((e) => e[0] === 'e')?.[1]; + const createdAt = formatCreatedAt(event.created_at); + + return ( +
+
+
+
+ +

+ reacted {event.content} 路 {createdAt} +

+
+
+
+
+
{root && }
+
+
+
+ ); +} diff --git a/src/app/lodge/components/repost.tsx b/src/app/lodge/components/repost.tsx new file mode 100644 index 00000000..21e6f807 --- /dev/null +++ b/src/app/lodge/components/repost.tsx @@ -0,0 +1,38 @@ +import { NDKEvent } from '@nostr-dev-kit/ndk'; + +import { SimpleNote } from '@app/lodge/components/simpleNote'; +import { NotiUser } from '@app/lodge/components/user'; + +import { useStorage } from '@libs/storage/provider'; + +import { formatCreatedAt } from '@utils/createdAt'; + +export function NotiRepost({ event }: { event: NDKEvent }) { + const { db } = useStorage(); + + const root = event.tags.find((e) => e[0] === 'e')?.[1]; + const createdAt = formatCreatedAt(event.created_at); + + return ( +
+
+
+
+ +

+ repost{' '} + {event.pubkey !== db.account.pubkey + ? 'a post that mention you' + : 'your post'}{' '} + 路 {createdAt} +

+
+
+
+
+
{root && }
+
+
+
+ ); +} diff --git a/src/app/lodge/components/simpleNote.tsx b/src/app/lodge/components/simpleNote.tsx new file mode 100644 index 00000000..df6443d1 --- /dev/null +++ b/src/app/lodge/components/simpleNote.tsx @@ -0,0 +1,61 @@ +import { memo } from 'react'; + +import { useStorage } from '@libs/storage/provider'; + +import { NoteSkeleton } from '@shared/notes'; +import { User } from '@shared/user'; + +import { WidgetKinds, useWidgets } from '@stores/widgets'; + +import { useEvent } from '@utils/hooks/useEvent'; + +export const SimpleNote = memo(function SimpleNote({ id }: { id: string }) { + const { db } = useStorage(); + const { status, data } = useEvent(id); + + const setWidget = useWidgets((state) => state.setWidget); + + const openThread = (event, thread: string) => { + const selection = window.getSelection(); + if (selection.toString().length === 0) { + setWidget(db, { kind: WidgetKinds.thread, title: 'Thread', content: thread }); + } else { + event.stopPropagation(); + } + }; + + if (status === 'loading') { + return ( +
+ +
+ ); + } + + if (status === 'error') { + return ( +
+

Can't get event from relay

+
+ ); + } + + return ( +
openThread(e, id)} + onKeyDown={(e) => openThread(e, id)} + role="button" + tabIndex={0} + className="mb-2 mt-3 cursor-default rounded-lg bg-white/10 px-3 py-3" + > + +
+

+ {data.content.length > 200 + ? data.content.substring(0, 200) + '...' + : data.content} +

+
+
+ ); +}); diff --git a/src/app/notification/components/user.tsx b/src/app/lodge/components/user.tsx similarity index 94% rename from src/app/notification/components/user.tsx rename to src/app/lodge/components/user.tsx index b7683453..3b5cd892 100644 --- a/src/app/notification/components/user.tsx +++ b/src/app/lodge/components/user.tsx @@ -22,7 +22,7 @@ export function NotiUser({ pubkey }: { pubkey: string }) { {pubkey} {user?.nip05 || user?.name || user?.display_name || displayNpub(pubkey, 16)} diff --git a/src/app/lodge/index.tsx b/src/app/lodge/index.tsx new file mode 100644 index 00000000..1f965f47 --- /dev/null +++ b/src/app/lodge/index.tsx @@ -0,0 +1,85 @@ +import { NDKEvent, NDKFilter } from '@nostr-dev-kit/ndk'; +import { useQuery } from '@tanstack/react-query'; +import { useCallback, useEffect } from 'react'; + +import { NotiMention } from '@app/lodge/components/mention'; +import { NotiReaction } from '@app/lodge/components/reaction'; +import { NotiRepost } from '@app/lodge/components/repost'; + +import { useStorage } from '@libs/storage/provider'; + +import { LoaderIcon } from '@shared/icons'; +import { TitleBar } from '@shared/titleBar'; + +import { useNostr } from '@utils/hooks/useNostr'; + +export function LodgeScreen() { + const { db } = useStorage(); + const { sub, fetchActivities } = useNostr(); + const { status, data } = useQuery( + ['lodge', db.account.pubkey], + async () => { + return await fetchActivities(); + }, + { refetchOnWindowFocus: false } + ); + + const renderItem = useCallback( + (event: NDKEvent) => { + switch (event.kind) { + case 1: + return ; + case 6: + return ; + case 7: + return ; + default: + return null; + } + }, + [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 ( +
+
+
+ +
+
+ {status === 'loading' ? ( +
+
+ +

Loading

+
+
+ ) : data?.length < 1 ? ( +
+

馃帀

+

+ Yo!, you've no new activities +

+
+ ) : ( + data.map((event) => renderItem(event)) + )} +
+
+
+
+
+ ); +} diff --git a/src/app/notification/components/mention.tsx b/src/app/notification/components/mention.tsx deleted file mode 100644 index 7191b439..00000000 --- a/src/app/notification/components/mention.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { NDKEvent } from '@nostr-dev-kit/ndk'; -import { useMemo } from 'react'; - -import { NotiContent } from '@app/notification/components/content'; -import { NotiUser } from '@app/notification/components/user'; - -import { formatCreatedAt } from '@utils/createdAt'; -import { parser } from '@utils/parser'; - -export function NotiMention({ event }: { event: NDKEvent }) { - const createdAt = formatCreatedAt(event.created_at); - const content = useMemo(() => parser(event), [event]); - - return ( -
-
-
- -

mention you 路 {createdAt}

-
-
-
-
- -
-
- ); -} diff --git a/src/app/notification/components/reaction.tsx b/src/app/notification/components/reaction.tsx deleted file mode 100644 index ad07c800..00000000 --- a/src/app/notification/components/reaction.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { NDKEvent } from '@nostr-dev-kit/ndk'; - -import { NotiUser } from '@app/notification/components/user'; - -import { MentionNote } from '@shared/notes'; - -import { formatCreatedAt } from '@utils/createdAt'; - -export function NotiReaction({ event }: { event: NDKEvent }) { - const root = event.tags.find((e) => e[0] === 'e')?.[1]; - const createdAt = formatCreatedAt(event.created_at); - - return ( -
-
-
- -

- reacted {event.content} 路 {createdAt} -

-
-
-
-
-
{root && }
-
-
- ); -} diff --git a/src/app/notification/components/repost.tsx b/src/app/notification/components/repost.tsx deleted file mode 100644 index c98081cb..00000000 --- a/src/app/notification/components/repost.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { NDKEvent } from '@nostr-dev-kit/ndk'; - -import { NotiUser } from '@app/notification/components/user'; - -import { MentionNote } from '@shared/notes'; - -import { formatCreatedAt } from '@utils/createdAt'; - -export function NotiRepost({ event }: { event: NDKEvent }) { - const root = event.tags.find((e) => e[0] === 'e')?.[1]; - const createdAt = formatCreatedAt(event.created_at); - - return ( -
-
-
- -

repostr your postr 路 {createdAt}

-
-
-
-
-
{root && }
-
-
- ); -} diff --git a/src/app/notification/index.tsx b/src/app/notification/index.tsx deleted file mode 100644 index e6ea7f1b..00000000 --- a/src/app/notification/index.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import { NDKEvent, NDKFilter } from '@nostr-dev-kit/ndk'; -import { useQuery } from '@tanstack/react-query'; -import { useCallback, useEffect } from 'react'; - -import { NotiMention } from '@app/notification/components/mention'; -import { NotiReaction } from '@app/notification/components/reaction'; -import { NotiRepost } from '@app/notification/components/repost'; - -import { useStorage } from '@libs/storage/provider'; - -import { LoaderIcon } from '@shared/icons'; - -import { useNostr } from '@utils/hooks/useNostr'; - -export function NotificationScreen() { - const { db } = useStorage(); - const { sub, fetchActivities } = useNostr(); - const { status, data } = useQuery( - ['notification', db.account.pubkey], - async () => { - return await fetchActivities(); - }, - { refetchOnWindowFocus: false } - ); - - const renderItem = useCallback( - (event: NDKEvent) => { - switch (event.kind) { - case 1: - return ; - case 6: - return ; - case 7: - return ; - default: - return null; - } - }, - [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 ( -
-
-

Notifications

-
-
-
- {status === 'loading' ? ( -
- -
- ) : data?.length < 1 ? ( -
-

馃帀

-

- Yo!, you've no new notifications -

-
- ) : ( - data.map((event) => renderItem(event)) - )} -
-
-
- ); -} diff --git a/src/app/space/components/widgets/feed.tsx b/src/app/space/components/widgets/feed.tsx index 1858dba3..ca9046d7 100644 --- a/src/app/space/components/widgets/feed.tsx +++ b/src/app/space/components/widgets/feed.tsx @@ -130,7 +130,7 @@ export function FeedWidget({ params }: { params: Widget }) {

- There have been no new postrs. + There have been no new posts.

diff --git a/src/app/space/components/widgets/hashtag.tsx b/src/app/space/components/widgets/hashtag.tsx index d14e6e65..93feff84 100644 --- a/src/app/space/components/widgets/hashtag.tsx +++ b/src/app/space/components/widgets/hashtag.tsx @@ -128,7 +128,7 @@ export function HashtagWidget({ params }: { params: Widget }) {

- There have been no new postrs with this hashtag in the last 24 hours. + There have been no new posts with this hashtag in the last 24 hours.

diff --git a/src/app/space/components/widgets/network.tsx b/src/app/space/components/widgets/network.tsx index 32c17eeb..eae70a77 100644 --- a/src/app/space/components/widgets/network.tsx +++ b/src/app/space/components/widgets/network.tsx @@ -167,7 +167,7 @@ export function NetworkWidget() {

- You not have any postrs to see yet + You not have any posts to see yet
Follow more people to have more fun.

diff --git a/src/app/space/components/widgets/user.tsx b/src/app/space/components/widgets/user.tsx index 25970558..6bd516d3 100644 --- a/src/app/space/components/widgets/user.tsx +++ b/src/app/space/components/widgets/user.tsx @@ -127,7 +127,7 @@ export function UserWidget({ params }: { params: Widget }) {
-

Latest postrs

+

Latest posts

{status === 'loading' ? (
@@ -140,7 +140,7 @@ export function UserWidget({ params }: { params: Widget }) {

- No new postr from user in 24 hours ago + No new post from user in 24 hours ago

diff --git a/src/app/users/index.tsx b/src/app/users/index.tsx index 270170cc..0fd4e123 100644 --- a/src/app/users/index.tsx +++ b/src/app/users/index.tsx @@ -120,7 +120,7 @@ export function UserScreen() {

- Latest postrs + Latest posts

{status === 'loading' ? ( @@ -134,7 +134,7 @@ export function UserScreen() {

- User doesn't have any postrs in the last 48 hours. + User doesn't have any posts in the last 48 hours.

diff --git a/src/shared/composer/composer.tsx b/src/shared/composer/composer.tsx index ec7ca82f..faa3b1cb 100644 --- a/src/shared/composer/composer.tsx +++ b/src/shared/composer/composer.tsx @@ -111,7 +111,7 @@ export function Composer() { await publish({ content: serializedContent, kind: 1, tags }); // send native notifiation - await sendNativeNotification('Publish postr successfully'); + await sendNativeNotification('Publish post successfully'); // update state setStatus('done'); @@ -166,7 +166,7 @@ export function Composer() { {status === 'loading' ? ( ) : ( - 'Postr' + 'Post' )}
diff --git a/src/shared/composer/modal.tsx b/src/shared/composer/modal.tsx index 085ca64c..51ab9dc8 100644 --- a/src/shared/composer/modal.tsx +++ b/src/shared/composer/modal.tsx @@ -21,7 +21,7 @@ export function ComposerModal() {
diff --git a/src/shared/navigation.tsx b/src/shared/navigation.tsx index be144e58..1c708115 100644 --- a/src/shared/navigation.tsx +++ b/src/shared/navigation.tsx @@ -85,7 +85,7 @@ export function Navigation() { Space twMerge( @@ -97,7 +97,7 @@ export function Navigation() { - Notifications + Lodge
diff --git a/src/shared/notes/actions/more.tsx b/src/shared/notes/actions/more.tsx index 8e40688c..f54c1933 100644 --- a/src/shared/notes/actions/more.tsx +++ b/src/shared/notes/actions/more.tsx @@ -51,7 +51,7 @@ export function MoreActions({ id, pubkey }: { id: string; pubkey: string }) { to={`/notes/text/${id}`} className="inline-flex h-10 items-center rounded-md px-2 text-sm font-medium text-white hover:bg-white/10" > - Open as new screen + Focus mode diff --git a/src/shared/notes/actions/repost.tsx b/src/shared/notes/actions/repost.tsx index ef1413c2..8034b059 100644 --- a/src/shared/notes/actions/repost.tsx +++ b/src/shared/notes/actions/repost.tsx @@ -38,7 +38,7 @@ export function NoteRepost({ id, pubkey }: { id: string; pubkey: string }) { - Repostr + Repost @@ -49,11 +49,11 @@ export function NoteRepost({ id, pubkey }: { id: string; pubkey: string }) {
- Confirm repostr this postr? + Confirm repost this post? - Repostred postr will be visible to your followers, and you cannot undo - this action. + Reposted post will be visible to your followers, and you cannot undo this + action.
@@ -67,7 +67,7 @@ export function NoteRepost({ id, pubkey }: { id: string; pubkey: string }) { onClick={() => submit()} className="inline-flex h-11 items-center justify-center rounded-lg bg-fuchsia-500 px-4 font-medium leading-none text-white outline-none" > - Yes, repostr + Yes, repost
diff --git a/src/shared/notes/kinds/repost.tsx b/src/shared/notes/kinds/repost.tsx index 96d12368..86b2e10e 100644 --- a/src/shared/notes/kinds/repost.tsx +++ b/src/shared/notes/kinds/repost.tsx @@ -33,7 +33,7 @@ export function Repost({ event }: { event: NDKEvent }) {

- Failed to get repostr with ID + Failed to get repost with ID

{repostID}

diff --git a/src/shared/notes/stats.tsx b/src/shared/notes/stats.tsx index f16424bc..ea7f4e42 100644 --- a/src/shared/notes/stats.tsx +++ b/src/shared/notes/stats.tsx @@ -72,7 +72,7 @@ export function NoteStats({ id }: { id: string }) { {compactNumber.format(data.reposts)} {' '} - repostrs + reposts