@linktr.ee/messaging-react 1.11.4 → 1.11.5-rc-1765008275

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -111,7 +111,16 @@ export const MessagingShell: React.FC<MessagingShellProps> = ({
111
111
  })
112
112
  })
113
113
 
114
- setExistingParticipantIds(memberIds)
114
+ // Only update if the set contents have changed to prevent re-renders
115
+ setExistingParticipantIds((prev) => {
116
+ if (
117
+ prev.size === memberIds.size &&
118
+ [...prev].every((id) => memberIds.has(id))
119
+ ) {
120
+ return prev
121
+ }
122
+ return memberIds
123
+ })
115
124
  setHasChannels(channels.length > 0)
116
125
  syncedRef.current = userId // Mark as synced for this user
117
126
 
@@ -315,6 +324,15 @@ export const MessagingShell: React.FC<MessagingShellProps> = ({
315
324
  participantPickerRef.current?.close()
316
325
  }, [])
317
326
 
327
+ const handleDialogBackdropClick = useCallback(
328
+ (e: React.MouseEvent<HTMLDialogElement>) => {
329
+ if (e.target === participantPickerRef.current) {
330
+ handleCloseParticipantPicker()
331
+ }
332
+ },
333
+ [handleCloseParticipantPicker]
334
+ )
335
+
318
336
  const handleLeaveConversation = useCallback(
319
337
  async (channel: Channel) => {
320
338
  if (debug) {
@@ -459,11 +477,7 @@ export const MessagingShell: React.FC<MessagingShellProps> = ({
459
477
  <dialog
460
478
  ref={participantPickerRef}
461
479
  className="mes-dialog"
462
- onClick={(e) => {
463
- if (e.target === participantPickerRef.current) {
464
- handleCloseParticipantPicker()
465
- }
466
- }}
480
+ onClick={handleDialogBackdropClick}
467
481
  onClose={handleCloseParticipantPicker}
468
482
  >
469
483
  <div className="h-full w-full bg-white shadow-max-elevation-light">