Skip to content

Commit

Permalink
Fix issue where event listeners not added
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Sep 6, 2023
1 parent c28759d commit cc6642a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/components/chat/ChatIframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ export default function ChatIframe({ onUnreadCountChange, ...props }: ChatIframe
return iframe
}

const listener: GrillEventListener | undefined = onUnreadCountChange
? (name, value) => {
const parsedValue = parseInt(value) ?? 0
if (name === 'unread') onUnreadCountChange(parsedValue)
else if (name === 'totalMessage') setChatTotalMessageCount(parsedValue)
}
: undefined
const listener: GrillEventListener | undefined = (name, value) => {
const parsedValue = parseInt(value) ?? 0
if (name === 'unread') onUnreadCountChange?.(parsedValue)
else if (name === 'totalMessage') setChatTotalMessageCount(parsedValue)
}
if (listener) {
grill.addUnreadCountListener(listener)
}
Expand Down

0 comments on commit cc6642a

Please sign in to comment.