added reply message to channel

This commit is contained in:
Ren Amamiya
2023-04-12 10:03:16 +07:00
parent ac5e78a6b8
commit d8d3113fb9
21 changed files with 336 additions and 70 deletions

View File

@@ -1,10 +1,13 @@
import BaseLayout from '@layouts/base';
import WithSidebarLayout from '@layouts/withSidebar';
import { ChannelMessageList } from '@components/channels/channelMessageList';
import { ChannelMessages } from '@components/channels/messages/index';
import FormChannelMessage from '@components/form/channelMessage';
import { RelayContext } from '@components/relaysProvider';
import { channelReplyAtom } from '@stores/channel';
import { useResetAtom } from 'jotai/utils';
import { useRouter } from 'next/router';
import {
JSXElementConstructor,
@@ -23,8 +26,12 @@ export default function Page() {
const id: string | string[] = router.query.id || null;
const [messages, setMessages] = useState([]);
const resetChannelReply = useResetAtom(channelReplyAtom);
useEffect(() => {
// reset channel reply
resetChannelReply();
// subscribe event
const unsubscribe = pool.subscribe(
[
{
@@ -42,11 +49,11 @@ export default function Page() {
return () => {
unsubscribe;
};
}, [id, pool, relays]);
}, [id, pool, relays, resetChannelReply]);
return (
<div className="flex h-full w-full flex-col justify-between">
<ChannelMessageList data={messages.sort((a, b) => a.created_at - b.created_at)} />
<ChannelMessages data={messages.sort((a, b) => a.created_at - b.created_at)} />
<div className="shrink-0 p-3">
<FormChannelMessage eventId={id} />
</div>

View File

@@ -16,7 +16,7 @@ export default function Page() {
const fetchFollowsByAccount = useCallback(async (id) => {
const { getPlebs } = await import('@utils/bindings');
return await getPlebs({ account_id: id });
return await getPlebs({ account_id: id, kind: 0 });
}, []);
useEffect(() => {

View File

@@ -84,7 +84,7 @@ export default function Page() {
setLoading(true);
for (const follow of follows) {
const metadata: any = await fetchMetadata(follow, pool, relays);
const metadata: any = await fetchMetadata(follow);
createPleb({
pleb_id: follow + '-lume' + id,
pubkey: follow,

View File

@@ -49,7 +49,7 @@ export default function Page() {
const { createPleb } = await import('@utils/bindings');
if (profile?.id !== null) {
for (const tag of tags) {
const metadata: any = await fetchMetadata(tag[1], pool, relays);
const metadata: any = await fetchMetadata(tag[1]);
createPleb({
pleb_id: tag[1] + '-lume' + profile.id.toString(),
pubkey: tag[1],
@@ -60,7 +60,7 @@ export default function Page() {
}
}
},
[pool, profile.id, relays]
[profile.id]
);
useEffect(() => {