From 6a0a5ed31feb94ceabb39c89a26cab4ccd040472 Mon Sep 17 00:00:00 2001 From: Sasha Date: Wed, 6 Dec 2023 01:27:34 +0530 Subject: [PATCH] allow to change pubsub topic --- src/app/components/Waku.tsx | 76 ++++++++++++++++++++++++++----------- src/app/page.tsx | 6 ++- src/constants.ts | 12 +++++- src/hooks/useWaku.ts | 24 ++++++++---- src/services/waku.ts | 17 ++++++--- 5 files changed, 97 insertions(+), 38 deletions(-) diff --git a/src/app/components/Waku.tsx b/src/app/components/Waku.tsx index 3364ca0..e1d1082 100644 --- a/src/app/components/Waku.tsx +++ b/src/app/components/Waku.tsx @@ -3,12 +3,15 @@ import { Block } from "@/components/Block"; import { Subtitle } from "@/components/Subtitle"; import { Button } from "@/components/Button"; import { MessageContent } from "@/hooks"; +import { SUPPORTED_PUBSUB_TOPICS } from "@/constants"; type WakuProps = { onSend: (nick: string, text: string) => Promise; activeContentTopic: string; + activePubsubTopic: string; messages: MessageContent[]; onActiveContentTopicChange: (contentTopic: string) => void; + onActivePubsubTopicChange: (pubsubTopic: string) => void; } export const Waku: React.FunctionComponent = (props) => { @@ -19,10 +22,14 @@ export const Waku: React.FunctionComponent = (props) => { onMessageChange, resetText, } = useMessage(); - const { + const [ contentTopic, onContentTopicChange, - } = useContentTopic(props.activeContentTopic); + ] = useTopic(props.activeContentTopic); + const [ + pubsubTopic, + onPubsubTopicChange, + ] = useTopic(props.activePubsubTopic); const onSendClick = async () => { await props.onSend(nick, text); @@ -38,18 +45,40 @@ export const Waku: React.FunctionComponent = (props) => { - - Waku - + Chat + + + + + + + + + + = (props) => { = (props) => { /> - +