From e5c9a06368b6ccb90de11d2a6760de03f5b97dde Mon Sep 17 00:00:00 2001 From: Danish Arora <35004822+danisharora099@users.noreply.github.com> Date: Mon, 4 Nov 2024 21:57:12 +0530 Subject: [PATCH] chore(buddybook): improvements (#106) --- examples/buddybook/src/App.tsx | 20 ++- .../Chain/Create/CreationPreview.tsx | 10 +- .../src/components/Chain/SignChain.tsx | 99 +++++++----- .../src/components/Chain/View/ChainList.tsx | 2 +- examples/buddybook/src/components/Header.tsx | 144 ++++++++---------- examples/buddybook/src/components/QRCode.tsx | 11 +- .../buddybook/src/components/ui/button.tsx | 6 +- examples/buddybook/src/components/ui/card.tsx | 2 +- .../buddybook/src/components/ui/dialog.tsx | 28 ++-- .../buddybook/src/components/ui/input.tsx | 3 +- .../buddybook/src/components/ui/textarea.tsx | 3 +- .../buddybook/src/hooks/useWalletPrompt.ts | 19 ++- examples/buddybook/src/index.css | 30 ++-- 13 files changed, 201 insertions(+), 176 deletions(-) diff --git a/examples/buddybook/src/App.tsx b/examples/buddybook/src/App.tsx index 2643810..34f8f5d 100644 --- a/examples/buddybook/src/App.tsx +++ b/examples/buddybook/src/App.tsx @@ -71,13 +71,17 @@ function App() { setIsLoadingChains(true); const messageGenerator = getMessagesFromStore(node as LightNode); - // Process messages as they arrive - for await (const message of messageGenerator) { - setChainsData(prevChains => { - const blockExists = prevChains.some(block => block.blockUUID === message.blockUUID); - if (blockExists) return prevChains; - return [...prevChains, message]; - }); + try { + for await (const message of messageGenerator) { + setChainsData(prevChains => { + const blockExists = prevChains.some(block => block.blockUUID === message.blockUUID); + if (blockExists) return prevChains; + return [...prevChains, message]; + }); + } + } catch (error) { + console.error("Error processing message:", error); + // Continue processing other messages } setWakuStatus(prev => ({ ...prev, store: 'success' })); @@ -130,9 +134,9 @@ function App() {
+ } /> } /> } /> - } /> { value={formData.title} onChange={handleInputChange} maxLength={50} + className="text-base sm:text-sm" /> {errors.title &&

{errors.title}

} @@ -156,10 +157,11 @@ const ChainCreationForm: React.FC = () => { value={formData.description} onChange={handleInputChange} maxLength={500} + className="min-h-[100px] text-base sm:text-sm" /> {errors.description &&

{errors.description}

} - + @@ -196,15 +198,15 @@ const ChainCreationForm: React.FC = () => { <>

- {`${window.location.origin}/sign/${formData.uuid}/${createdBlockUUID}`} + {`${window.location.origin}${import.meta.env.BASE_URL}sign/${formData.uuid}/${createdBlockUUID}`}

@@ -157,6 +172,8 @@ const SignChain: React.FC = ({ block, chainsData, onSuccess }) = ) : alreadySigned ? ( 'Already Signed' + ) : !address ? ( + 'Connect Wallet' ) : ( 'Sign' )} diff --git a/examples/buddybook/src/components/Chain/View/ChainList.tsx b/examples/buddybook/src/components/Chain/View/ChainList.tsx index da40388..c21375d 100644 --- a/examples/buddybook/src/components/Chain/View/ChainList.tsx +++ b/examples/buddybook/src/components/Chain/View/ChainList.tsx @@ -23,7 +23,7 @@ const ChainList: React.FC = ({ chainsData, onChainUpdate, isLoad const childBlocks = chainsData.filter(b => b.parentBlockUUID === block.blockUUID); const totalSignatures = block.signatures.length + childBlocks.reduce((acc, child) => acc + child.signatures.length, 0); - const shareUrl = `${window.location.origin}/sign/${block.chainUUID ?? block.blockUUID}/${block.blockUUID}`; + const shareUrl = `${window.location.origin}${import.meta.env.BASE_URL}sign/${block.chainUUID ?? block.blockUUID}/${block.blockUUID}`; return (
  • diff --git a/examples/buddybook/src/components/Header.tsx b/examples/buddybook/src/components/Header.tsx index 180e008..f659cd2 100644 --- a/examples/buddybook/src/components/Header.tsx +++ b/examples/buddybook/src/components/Header.tsx @@ -56,90 +56,70 @@ const Header: React.FC = ({ wakuStatus }) => { }; return ( -
    -
    -
    -
    -

    BuddyBook

    -