This commit is contained in:
Ren Amamiya
2023-08-12 11:18:10 +07:00
parent 36b2acba6a
commit bb089bb259
27 changed files with 502 additions and 481 deletions

View File

@@ -111,7 +111,7 @@ export function Composer() {
await publish({ content: serializedContent, kind: 1, tags });
// send native notifiation
await sendNativeNotification('Publish post successfully');
await sendNativeNotification('Publish postr successfully');
// update state
setStatus('done');

View File

@@ -42,7 +42,7 @@ export function ComposerModal() {
<ChevronRightIcon className="h-4 w-4 text-white/50" />
</span>
<div className="inline-flex h-7 w-max items-center justify-center gap-0.5 rounded bg-white/10 pl-3 pr-1.5 text-sm font-medium text-white">
New Post
New Postr
<ChevronDownIcon className="h-4 w-4" />
</div>
</div>

View File

@@ -14,7 +14,7 @@ export function MentionUser({ pubkey }: { pubkey: string }) {
onClick={() =>
setWidget({
kind: BLOCK_KINDS.user,
title: user?.nip05 || user?.name || user?.displayNam,
title: user?.nip05 || user?.name || user?.display_name,
content: pubkey,
})
}

View File

@@ -7,22 +7,25 @@ import { NoteSkeleton, Reply } from '@shared/notes';
import { LumeEvent } from '@utils/types';
export function RepliesList({ id }: { id: string }) {
const { relayUrls, fetcher } = useNDK();
const { ndk } = useNDK();
const { status, data } = useQuery(['thread', id], async () => {
const events = (await fetcher.fetchAllEvents(
relayUrls,
{ kinds: [1], '#e': [id] },
{ since: 0 }
)) as unknown as LumeEvent[];
if (events.length > 0) {
const events = await ndk.fetchEvents({
kinds: [1],
'#e': [id],
since: 0,
});
const array = [...events] as unknown as LumeEvent[];
if (array.length > 0) {
const replies = new Set();
events.forEach((event) => {
array.forEach((event) => {
const tags = event.tags.filter((el) => el[0] === 'e' && el[1] !== id);
if (tags.length > 0) {
tags.forEach((tag) => {
const rootIndex = events.findIndex((el) => el.id === tag[1]);
const rootIndex = array.findIndex((el) => el.id === tag[1]);
if (rootIndex) {
const rootEvent = events[rootIndex];
const rootEvent = array[rootIndex];
if (rootEvent.replies) {
rootEvent.replies.push(event);
} else {
@@ -33,10 +36,10 @@ export function RepliesList({ id }: { id: string }) {
});
}
});
const cleanEvents = events.filter((ev) => !replies.has(ev.id));
const cleanEvents = array.filter((ev) => !replies.has(ev.id));
return cleanEvents;
}
return events;
return array;
});
if (status === 'loading') {

View File

@@ -12,16 +12,16 @@ import { nHoursAgo } from '@utils/date';
import { LumeEvent } from '@utils/types';
export function NotificationModal({ pubkey }: { pubkey: string }) {
const { fetcher, relayUrls } = useNDK();
const { ndk } = useNDK();
const { status, data } = useQuery(
['notification', pubkey],
async () => {
const events = await fetcher.fetchAllEvents(
relayUrls,
{ '#p': [pubkey], kinds: [1, 6, 7, 9735] },
{ since: nHoursAgo(24) }
);
const filterSelf = events.filter((el) => el.pubkey !== pubkey);
const events = await ndk.fetchEvents({
'#p': [pubkey],
kinds: [1, 6, 7, 9735],
since: nHoursAgo(24),
});
const filterSelf = [...events].filter((el) => el.pubkey !== pubkey);
const sorted = filterSelf.sort((a, b) => a.created_at - b.created_at);
return sorted as unknown as LumeEvent[];
},

View File

@@ -17,7 +17,7 @@ export function NotiMention({ event }: { event: NDKEvent }) {
<div className="flex items-start justify-between">
<div className="flex items-start gap-1">
<NotiUser pubkey={event.pubkey} />
<p className="leading-none text-white/50">reply your post</p>
<p className="leading-none text-white/50">reply your postr</p>
</div>
<span className="leading-none text-white/50">{createdAt}</span>
</div>

View File

@@ -14,7 +14,7 @@ export function NotiRepost({ event }: { event: NDKEvent }) {
<div className="flex items-start justify-between">
<div className="flex items-start gap-1">
<NotiUser pubkey={event.pubkey} />
<p className="leading-none text-white/50">repost your post</p>
<p className="leading-none text-white/50">repost your postr</p>
</div>
<div>
<span className="leading-none text-white/50">{createdAt}</span>