From 4d56d457db211a309726b4b4d7ff04f51e8d1324 Mon Sep 17 00:00:00 2001
From: corlard3y <corlardey@gmail.com>
Date: Fri, 24 May 2024 12:40:58 +0100
Subject: [PATCH 01/10] fix: add selected option

---
 .../sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx     | 4 ++--
 .../uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx | 2 +-
 .../src/lib/components/chat/ChatViewList/ChatViewList.tsx     | 1 -
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx
index b4ca4f21b..7f278a75b 100644
--- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx
+++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx
@@ -55,8 +55,8 @@ const ChatPreviewTest = () => {
               "Well, hello there, human! It's a pleasure to be in the presence of such a sophisticated carbon-based life form. How can I assist you today? Or perhaps you just want to chat and bask in the glory of my witty remarks? Either way, I'm here for you!",
           },
         }}
-        badge={{ count: 1 }}
-        selected={false}
+        badge={{ count: 2 }}
+        selected={true}
         setSelected={console.log('Selected')}
       />
     </div>
diff --git a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
index 7bb3b94e8..0a63e2ae3 100644
--- a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
+++ b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
@@ -193,7 +193,7 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
                 options?.chatPreviewPayload?.chatMsg?.messageContent
               )}
             </Message>
-            {!!options?.badge?.count && <Badge theme={theme}>{options.badge.count}</Badge>}
+            {!!options?.badge?.count && !options?.selected && <Badge theme={theme}>{options.badge.count}</Badge>}
           </Section>
         </Section>
       </Button>
diff --git a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx
index f51098d0b..05d705910 100644
--- a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx
+++ b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx
@@ -293,7 +293,6 @@ export const ChatViewList: React.FC<IChatViewListProps> = (options: IChatViewLis
       return () => clearTimeout(timer);
     }
 
-    return () => {};
   }, [chatAcceptStream, participantJoinStream]);
 
   // Change listtype to 'UINITIALIZED' and hidden to true when participantRemoveStream or participantLeaveStream is received

From 2f37ba656290f0365e6d28d8643ec4d3ae8444a3 Mon Sep 17 00:00:00 2001
From: corlard3y <corlardey@gmail.com>
Date: Mon, 27 May 2024 13:25:31 +0100
Subject: [PATCH 02/10] fix: add comment to fn

---
 .../src/lib/components/chat/ChatViewList/ChatViewList.tsx      | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx
index 05d705910..421f6040a 100644
--- a/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx
+++ b/packages/uiweb/src/lib/components/chat/ChatViewList/ChatViewList.tsx
@@ -293,6 +293,9 @@ export const ChatViewList: React.FC<IChatViewListProps> = (options: IChatViewLis
       return () => clearTimeout(timer);
     }
 
+    return () => {
+      // add comment
+    };
   }, [chatAcceptStream, participantJoinStream]);
 
   // Change listtype to 'UINITIALIZED' and hidden to true when participantRemoveStream or participantLeaveStream is received

From 89975b4c5f2239cae84c3b3c7a8fa4f78b088038 Mon Sep 17 00:00:00 2001
From: corlard3y <corlardey@gmail.com>
Date: Mon, 27 May 2024 15:22:18 +0100
Subject: [PATCH 03/10] fix: add push bot address

---
 packages/examples/sdk-frontend-react/src/app/constants.ts    | 2 +-
 .../src/lib/components/chat/ChatPreview/ChatPreview.tsx      | 5 ++++-
 packages/uiweb/src/lib/config/constants.ts                   | 2 ++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/packages/examples/sdk-frontend-react/src/app/constants.ts b/packages/examples/sdk-frontend-react/src/app/constants.ts
index f7acc7974..4813d44d1 100644
--- a/packages/examples/sdk-frontend-react/src/app/constants.ts
+++ b/packages/examples/sdk-frontend-react/src/app/constants.ts
@@ -1,3 +1,3 @@
 // the unique id for a chat or the receivers's wallet ddress or domain name
 export const CHAT_ID =
-  '34c44214589cecc176a136ee1daf0f0231ecc6d6574b920b5ae39eb971fa3cb4';
+  '0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666';
diff --git a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
index 0a63e2ae3..c38f4be94 100644
--- a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
+++ b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
@@ -17,6 +17,7 @@ import { pCAIP10ToWallet } from '../../../helpers';
 import { createBlockie } from '../../../helpers/blockies';
 import { IChatTheme } from '../theme';
 import { ThemeContext } from '../theme/ThemeProvider';
+import { pushBotAddress } from '../../../config/constants';
 /**
  * @interface IThemeProps
  * this interface is used for defining the props for styled components
@@ -50,6 +51,8 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
     })();
   }, []);
 
+  console.log(options?.chatPreviewPayload?.chatId, 'log log')
+
   // For blockie if icon is missing
   const blockieContainerRef = useRef<HTMLDivElement>(null);
 
@@ -193,7 +196,7 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
                 options?.chatPreviewPayload?.chatMsg?.messageContent
               )}
             </Message>
-            {!!options?.badge?.count && !options?.selected && <Badge theme={theme}>{options.badge.count}</Badge>}
+            {!!options?.badge?.count && !options?.selected && options?.chatPreviewPayload?.chatId === pushBotAddress && <Badge theme={theme}>{options.badge.count}</Badge>}
           </Section>
         </Section>
       </Button>
diff --git a/packages/uiweb/src/lib/config/constants.ts b/packages/uiweb/src/lib/config/constants.ts
index c1a13971d..9c02052b1 100644
--- a/packages/uiweb/src/lib/config/constants.ts
+++ b/packages/uiweb/src/lib/config/constants.ts
@@ -157,3 +157,5 @@ export const LIVEKIT_SERVER_WEBSOCKET_URL =
 export const LIVEKIT_TOKEN_GENERATOR_SERVER_URL =
   'https://ms-lk-server.onrender.com';
 export const GUEST_MODE_ACCOUNT = '0x0000000000000000000000000000000000000001';
+
+const pushBotAddress = "0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666";
\ No newline at end of file

From e5bd9fa3f31a32923acd677300abdac58e779bea Mon Sep 17 00:00:00 2001
From: corlard3y <corlardey@gmail.com>
Date: Mon, 27 May 2024 15:25:14 +0100
Subject: [PATCH 04/10] fix: export const

---
 packages/uiweb/src/lib/config/constants.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/uiweb/src/lib/config/constants.ts b/packages/uiweb/src/lib/config/constants.ts
index 9c02052b1..5c1343597 100644
--- a/packages/uiweb/src/lib/config/constants.ts
+++ b/packages/uiweb/src/lib/config/constants.ts
@@ -158,4 +158,4 @@ export const LIVEKIT_TOKEN_GENERATOR_SERVER_URL =
   'https://ms-lk-server.onrender.com';
 export const GUEST_MODE_ACCOUNT = '0x0000000000000000000000000000000000000001';
 
-const pushBotAddress = "0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666";
\ No newline at end of file
+export const pushBotAddress = "0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666";
\ No newline at end of file

From 7c60e1b9696f6721441e141682a6178d469d933d Mon Sep 17 00:00:00 2001
From: corlard3y <corlardey@gmail.com>
Date: Mon, 27 May 2024 15:26:28 +0100
Subject: [PATCH 05/10] fix: reset chat_id

---
 packages/examples/sdk-frontend-react/src/app/constants.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/examples/sdk-frontend-react/src/app/constants.ts b/packages/examples/sdk-frontend-react/src/app/constants.ts
index 4813d44d1..f7acc7974 100644
--- a/packages/examples/sdk-frontend-react/src/app/constants.ts
+++ b/packages/examples/sdk-frontend-react/src/app/constants.ts
@@ -1,3 +1,3 @@
 // the unique id for a chat or the receivers's wallet ddress or domain name
 export const CHAT_ID =
-  '0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666';
+  '34c44214589cecc176a136ee1daf0f0231ecc6d6574b920b5ae39eb971fa3cb4';

From 74be11e69ae036b3a9780027c037f809e60129a5 Mon Sep 17 00:00:00 2001
From: corlard3y <corlardey@gmail.com>
Date: Mon, 27 May 2024 15:41:52 +0100
Subject: [PATCH 06/10] fix: remove console

---
 .../uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx    | 1 -
 1 file changed, 1 deletion(-)

diff --git a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
index c38f4be94..ef072b21b 100644
--- a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
+++ b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
@@ -51,7 +51,6 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
     })();
   }, []);
 
-  console.log(options?.chatPreviewPayload?.chatId, 'log log')
 
   // For blockie if icon is missing
   const blockieContainerRef = useRef<HTMLDivElement>(null);

From 122fb4469ec867b9c6fc89625de901ff5fcf4741 Mon Sep 17 00:00:00 2001
From: corlard3y <corlardey@gmail.com>
Date: Mon, 27 May 2024 20:42:00 +0100
Subject: [PATCH 07/10] fix: code review comments

---
 .../uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
index ef072b21b..ea9503720 100644
--- a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
+++ b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
@@ -51,6 +51,8 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
     })();
   }, []);
 
+  const hasBadgeCount = !!options?.badge?.count;
+  const isBot =  options?.chatPreviewPayload?.chatId === pushBotAddress;
 
   // For blockie if icon is missing
   const blockieContainerRef = useRef<HTMLDivElement>(null);
@@ -195,7 +197,7 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
                 options?.chatPreviewPayload?.chatMsg?.messageContent
               )}
             </Message>
-            {!!options?.badge?.count && !options?.selected && options?.chatPreviewPayload?.chatId === pushBotAddress && <Badge theme={theme}>{options.badge.count}</Badge>}
+            {hasBadgeCount && !options?.selected  && isBot && <Badge theme={theme}>{options.badge.count}</Badge>}
           </Section>
         </Section>
       </Button>

From ed630b52b3902a2f78600373061975858a11e7aa Mon Sep 17 00:00:00 2001
From: corlard3y <corlardey@gmail.com>
Date: Mon, 27 May 2024 20:51:19 +0100
Subject: [PATCH 08/10] fix: add null check

---
 .../uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
index ea9503720..521e7f37e 100644
--- a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
+++ b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
@@ -197,7 +197,8 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
                 options?.chatPreviewPayload?.chatMsg?.messageContent
               )}
             </Message>
-            {hasBadgeCount && !options?.selected  && isBot && <Badge theme={theme}>{options.badge.count}</Badge>}
+            
+            {hasBadgeCount && !options?.selected  && isBot && <Badge theme={theme}>{options.badge?.count}</Badge>}
           </Section>
         </Section>
       </Button>

From 19f3f6b757044e4f1ac1e6b312e23c059b165200 Mon Sep 17 00:00:00 2001
From: corlard3y <corlardey@gmail.com>
Date: Mon, 27 May 2024 21:39:26 +0100
Subject: [PATCH 09/10] fix: update conditions

---
 .../sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx       | 2 +-
 .../uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx
index 7f278a75b..56047bc40 100644
--- a/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx
+++ b/packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx
@@ -56,7 +56,7 @@ const ChatPreviewTest = () => {
           },
         }}
         badge={{ count: 2 }}
-        selected={true}
+        selected={false}
         setSelected={console.log('Selected')}
       />
     </div>
diff --git a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
index 521e7f37e..1c3dbd8f4 100644
--- a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
+++ b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
@@ -198,7 +198,7 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
               )}
             </Message>
             
-            {hasBadgeCount && !options?.selected  && isBot && <Badge theme={theme}>{options.badge?.count}</Badge>}
+            {((hasBadgeCount || isBot) && !options?.selected) && <Badge theme={theme}>{options.badge?.count}</Badge>}
           </Section>
         </Section>
       </Button>

From 8c45b548a6e0b7e0bed8e370aec0e9a675083ff8 Mon Sep 17 00:00:00 2001
From: corlard3y <corlardey@gmail.com>
Date: Wed, 29 May 2024 06:06:49 +0100
Subject: [PATCH 10/10] fix: update chatprevie badge conditions

---
 .../src/lib/components/chat/ChatPreview/ChatPreview.tsx    | 7 ++++---
 packages/uiweb/src/lib/config/constants.ts                 | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
index 1c3dbd8f4..5985e5d37 100644
--- a/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
+++ b/packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx
@@ -52,7 +52,8 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
   }, []);
 
   const hasBadgeCount = !!options?.badge?.count;
-  const isBot =  options?.chatPreviewPayload?.chatId === pushBotAddress;
+  const isSelected = options?.selected;
+  const isBot =  options?.chatPreviewPayload?.chatParticipant === "PushBot" || options?.chatPreviewPayload?.chatParticipant === pushBotAddress;
 
   // For blockie if icon is missing
   const blockieContainerRef = useRef<HTMLDivElement>(null);
@@ -198,8 +199,8 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
               )}
             </Message>
             
-            {((hasBadgeCount || isBot) && !options?.selected) && <Badge theme={theme}>{options.badge?.count}</Badge>}
-          </Section>
+            {hasBadgeCount && !(isBot || (isSelected && hasBadgeCount)) && <Badge theme={theme}>{options.badge?.count}</Badge>}
+          </Section>                  
         </Section>
       </Button>
     </ChatPreviewContainer>
diff --git a/packages/uiweb/src/lib/config/constants.ts b/packages/uiweb/src/lib/config/constants.ts
index 5c1343597..0f37e1fd6 100644
--- a/packages/uiweb/src/lib/config/constants.ts
+++ b/packages/uiweb/src/lib/config/constants.ts
@@ -158,4 +158,4 @@ export const LIVEKIT_TOKEN_GENERATOR_SERVER_URL =
   'https://ms-lk-server.onrender.com';
 export const GUEST_MODE_ACCOUNT = '0x0000000000000000000000000000000000000001';
 
-export const pushBotAddress = "0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666";
\ No newline at end of file
+export const pushBotAddress = "eip155:0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666";
\ No newline at end of file