Skip to content

Commit 06254e6

Browse files
authored
Merge pull request #1323 from push-protocol/1320-bug-chat-badge
🐛 [BUG] - Chat badge getting updated for active/opened conversation>
2 parents 8512e41 + 8c45b54 commit 06254e6

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

packages/examples/sdk-frontend-react/src/app/ChatUITest/ChatPreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const ChatPreviewTest = () => {
5555
"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!",
5656
},
5757
}}
58-
badge={{ count: 1 }}
58+
badge={{ count: 2 }}
5959
selected={false}
6060
setSelected={console.log('Selected')}
6161
/>

packages/uiweb/src/lib/components/chat/ChatPreview/ChatPreview.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { pCAIP10ToWallet } from '../../../helpers';
1717
import { createBlockie } from '../../../helpers/blockies';
1818
import { IChatTheme } from '../theme';
1919
import { ThemeContext } from '../theme/ThemeProvider';
20+
import { pushBotAddress } from '../../../config/constants';
2021
/**
2122
* @interface IThemeProps
2223
* this interface is used for defining the props for styled components
@@ -50,6 +51,10 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
5051
})();
5152
}, []);
5253

54+
const hasBadgeCount = !!options?.badge?.count;
55+
const isSelected = options?.selected;
56+
const isBot = options?.chatPreviewPayload?.chatParticipant === "PushBot" || options?.chatPreviewPayload?.chatParticipant === pushBotAddress;
57+
5358
// For blockie if icon is missing
5459
const blockieContainerRef = useRef<HTMLDivElement>(null);
5560

@@ -194,8 +199,9 @@ export const ChatPreview: React.FC<IChatPreviewProps> = (options: IChatPreviewPr
194199
options?.chatPreviewPayload?.chatMsg?.messageContent
195200
)}
196201
</Message>
197-
{!!options?.badge?.count && <Badge theme={theme}>{options.badge.count}</Badge>}
198-
</Section>
202+
203+
{hasBadgeCount && !(isBot || (isSelected && hasBadgeCount)) && <Badge theme={theme}>{options.badge?.count}</Badge>}
204+
</Section>
199205
</Section>
200206
</Button>
201207
</ChatPreviewContainer>

packages/uiweb/src/lib/config/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,5 @@ export const LIVEKIT_SERVER_WEBSOCKET_URL =
157157
export const LIVEKIT_TOKEN_GENERATOR_SERVER_URL =
158158
'https://ms-lk-server.onrender.com';
159159
export const GUEST_MODE_ACCOUNT = '0x0000000000000000000000000000000000000001';
160+
161+
export const pushBotAddress = "eip155:0x99A08ac6254dcf7ccc37CeC662aeba8eFA666666";

0 commit comments

Comments
 (0)