added get channels
This commit is contained in:
55
src/pages/channels/[id].tsx
Normal file
55
src/pages/channels/[id].tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
import BaseLayout from '@layouts/base';
|
||||
import WithSidebarLayout from '@layouts/withSidebar';
|
||||
|
||||
import { RelayContext } from '@components/relaysProvider';
|
||||
|
||||
import { useRouter } from 'next/router';
|
||||
import { JSXElementConstructor, ReactElement, ReactFragment, ReactPortal, useContext, useEffect } from 'react';
|
||||
|
||||
export default function Page() {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
|
||||
const router = useRouter();
|
||||
const id: string | string[] = router.query.id || null;
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = pool.subscribe(
|
||||
[
|
||||
{
|
||||
kinds: [42],
|
||||
since: 0,
|
||||
},
|
||||
],
|
||||
relays,
|
||||
(event: any) => {
|
||||
console.log(event);
|
||||
}
|
||||
);
|
||||
|
||||
return () => {
|
||||
unsubscribe;
|
||||
};
|
||||
}, [pool, relays]);
|
||||
|
||||
return (
|
||||
<div className="flex h-full w-full flex-col justify-between">
|
||||
<p>{id}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Page.getLayout = function getLayout(
|
||||
page:
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| ReactElement<unknown, string | JSXElementConstructor<unknown>>
|
||||
| ReactFragment
|
||||
| ReactPortal
|
||||
) {
|
||||
return (
|
||||
<BaseLayout>
|
||||
<WithSidebarLayout>{page}</WithSidebarLayout>
|
||||
</BaseLayout>
|
||||
);
|
||||
};
|
||||
@@ -48,6 +48,14 @@ export function createChannel(data: CreateChannelData) {
|
||||
return invoke<Channel>('create_channel', { data });
|
||||
}
|
||||
|
||||
export function getChannels(data: GetChannelData) {
|
||||
return invoke<Channel[]>('get_channels', { data });
|
||||
}
|
||||
|
||||
export function getActiveChannels(data: GetActiveChannelData) {
|
||||
return invoke<Channel[]>('get_active_channels', { data });
|
||||
}
|
||||
|
||||
export function createChat(data: CreateChatData) {
|
||||
return invoke<Chat>('create_chat', { data });
|
||||
}
|
||||
@@ -85,11 +93,13 @@ export type GetNoteByIdData = { event_id: string };
|
||||
export type Chat = { id: number; pubkey: string; createdAt: number; accountId: number };
|
||||
export type Account = { id: number; pubkey: string; privkey: string; active: boolean; metadata: string };
|
||||
export type GetChatData = { account_id: number };
|
||||
export type GetChannelData = { limit: number; offset: number };
|
||||
export type CreateChannelData = { event_id: string; content: string; account_id: number };
|
||||
export type GetPlebPubkeyData = { pubkey: string };
|
||||
export type Channel = { id: number; eventId: string; content: string; accountId: number };
|
||||
export type GetActiveChannelData = { active: boolean };
|
||||
export type GetPlebData = { account_id: number };
|
||||
export type CreateAccountData = { pubkey: string; privkey: string; metadata: string };
|
||||
export type Channel = { id: number; eventId: string; content: string; active: boolean; accountId: number };
|
||||
export type GetLatestNoteData = { date: number };
|
||||
export type Pleb = { id: number; plebId: string; pubkey: string; kind: number; metadata: string; accountId: number };
|
||||
export type GetNoteData = { date: number; limit: number; offset: number };
|
||||
|
||||
Reference in New Issue
Block a user