@ethora/chat-component-rn 26.7.10 → 26.8.2

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.
Files changed (151) hide show
  1. package/lib/commonjs/components/Header/HeaderRoomList.js +3 -1
  2. package/lib/commonjs/components/Header/HeaderRoomList.js.map +1 -1
  3. package/lib/commonjs/components/MainComponents/ChatWrapper.js +25 -0
  4. package/lib/commonjs/components/MainComponents/ChatWrapper.js.map +1 -1
  5. package/lib/commonjs/components/MainComponents/ReduxWrapper.js +24 -3
  6. package/lib/commonjs/components/MainComponents/ReduxWrapper.js.map +1 -1
  7. package/lib/commonjs/components/MessageBubble/MessageTranslate.js +16 -7
  8. package/lib/commonjs/components/MessageBubble/MessageTranslate.js.map +1 -1
  9. package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js +7 -3
  10. package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
  11. package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +12 -10
  12. package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
  13. package/lib/commonjs/components/Modals/ChatProfileModal/DeleteChatModal.js +9 -7
  14. package/lib/commonjs/components/Modals/ChatProfileModal/DeleteChatModal.js.map +1 -1
  15. package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js +3 -3
  16. package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
  17. package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js +8 -1
  18. package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js.map +1 -1
  19. package/lib/commonjs/components/RoomComponents/ChatRoomItem.js +32 -2
  20. package/lib/commonjs/components/RoomComponents/ChatRoomItem.js.map +1 -1
  21. package/lib/commonjs/components/styled/DateLabel.js +10 -3
  22. package/lib/commonjs/components/styled/DateLabel.js.map +1 -1
  23. package/lib/commonjs/components/styled/NewMessageLabel.js +3 -1
  24. package/lib/commonjs/components/styled/NewMessageLabel.js.map +1 -1
  25. package/lib/commonjs/components/styled/SendInput.js +6 -6
  26. package/lib/commonjs/components/styled/SendInput.js.map +1 -1
  27. package/lib/commonjs/context/xmppProvider.js +7 -0
  28. package/lib/commonjs/context/xmppProvider.js.map +1 -1
  29. package/lib/commonjs/helpers/getDataFromXml.js +24 -1
  30. package/lib/commonjs/helpers/getDataFromXml.js.map +1 -1
  31. package/lib/commonjs/helpers/insertMessageWithDelimiter.js +13 -0
  32. package/lib/commonjs/helpers/insertMessageWithDelimiter.js.map +1 -1
  33. package/lib/commonjs/helpers/isUnresolvedSenderId.js +6 -1
  34. package/lib/commonjs/helpers/isUnresolvedSenderId.js.map +1 -1
  35. package/lib/commonjs/helpers/resolveLangSource.js +38 -0
  36. package/lib/commonjs/helpers/resolveLangSource.js.map +1 -0
  37. package/lib/commonjs/helpers/xmppUsername.js +39 -0
  38. package/lib/commonjs/helpers/xmppUsername.js.map +1 -0
  39. package/lib/commonjs/hooks/useChatWrapperInit.js +4 -2
  40. package/lib/commonjs/hooks/useChatWrapperInit.js.map +1 -1
  41. package/lib/commonjs/i18n/strings.js +120 -0
  42. package/lib/commonjs/i18n/strings.js.map +1 -1
  43. package/lib/commonjs/i18n/useT.js +1 -1
  44. package/lib/commonjs/networking/stanzaHandlers.js +41 -70
  45. package/lib/commonjs/networking/stanzaHandlers.js.map +1 -1
  46. package/lib/commonjs/roomStore/persistence.js +17 -1
  47. package/lib/commonjs/roomStore/persistence.js.map +1 -1
  48. package/lib/commonjs/version.js +3 -1
  49. package/lib/commonjs/version.js.map +1 -1
  50. package/lib/module/components/Header/HeaderRoomList.js +3 -1
  51. package/lib/module/components/Header/HeaderRoomList.js.map +1 -1
  52. package/lib/module/components/MainComponents/ChatWrapper.js +26 -1
  53. package/lib/module/components/MainComponents/ChatWrapper.js.map +1 -1
  54. package/lib/module/components/MainComponents/ReduxWrapper.js +26 -5
  55. package/lib/module/components/MainComponents/ReduxWrapper.js.map +1 -1
  56. package/lib/module/components/MessageBubble/MessageTranslate.js +16 -7
  57. package/lib/module/components/MessageBubble/MessageTranslate.js.map +1 -1
  58. package/lib/module/components/Modals/AttachSheet/AttachSheet.js +7 -3
  59. package/lib/module/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
  60. package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +12 -10
  61. package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
  62. package/lib/module/components/Modals/ChatProfileModal/DeleteChatModal.js +9 -7
  63. package/lib/module/components/Modals/ChatProfileModal/DeleteChatModal.js.map +1 -1
  64. package/lib/module/components/Modals/NewChatModal/NewChatModal.js +3 -3
  65. package/lib/module/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
  66. package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js +8 -1
  67. package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js.map +1 -1
  68. package/lib/module/components/RoomComponents/ChatRoomItem.js +33 -3
  69. package/lib/module/components/RoomComponents/ChatRoomItem.js.map +1 -1
  70. package/lib/module/components/styled/DateLabel.js +10 -3
  71. package/lib/module/components/styled/DateLabel.js.map +1 -1
  72. package/lib/module/components/styled/NewMessageLabel.js +3 -1
  73. package/lib/module/components/styled/NewMessageLabel.js.map +1 -1
  74. package/lib/module/components/styled/SendInput.js +6 -6
  75. package/lib/module/components/styled/SendInput.js.map +1 -1
  76. package/lib/module/context/xmppProvider.js +7 -0
  77. package/lib/module/context/xmppProvider.js.map +1 -1
  78. package/lib/module/helpers/getDataFromXml.js +23 -1
  79. package/lib/module/helpers/getDataFromXml.js.map +1 -1
  80. package/lib/module/helpers/insertMessageWithDelimiter.js +13 -0
  81. package/lib/module/helpers/insertMessageWithDelimiter.js.map +1 -1
  82. package/lib/module/helpers/isUnresolvedSenderId.js +6 -1
  83. package/lib/module/helpers/isUnresolvedSenderId.js.map +1 -1
  84. package/lib/module/helpers/resolveLangSource.js +32 -0
  85. package/lib/module/helpers/resolveLangSource.js.map +1 -0
  86. package/lib/module/helpers/xmppUsername.js +35 -0
  87. package/lib/module/helpers/xmppUsername.js.map +1 -0
  88. package/lib/module/hooks/useChatWrapperInit.js +4 -2
  89. package/lib/module/hooks/useChatWrapperInit.js.map +1 -1
  90. package/lib/module/i18n/strings.js +120 -0
  91. package/lib/module/i18n/strings.js.map +1 -1
  92. package/lib/module/i18n/useT.js +1 -1
  93. package/lib/module/networking/stanzaHandlers.js +42 -71
  94. package/lib/module/networking/stanzaHandlers.js.map +1 -1
  95. package/lib/module/roomStore/persistence.js +17 -1
  96. package/lib/module/roomStore/persistence.js.map +1 -1
  97. package/lib/module/version.js +3 -1
  98. package/lib/module/version.js.map +1 -1
  99. package/lib/typescript/components/Header/HeaderRoomList.d.ts.map +1 -1
  100. package/lib/typescript/components/MainComponents/ChatWrapper.d.ts.map +1 -1
  101. package/lib/typescript/components/MainComponents/ReduxWrapper.d.ts.map +1 -1
  102. package/lib/typescript/components/MessageBubble/MessageTranslate.d.ts.map +1 -1
  103. package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts.map +1 -1
  104. package/lib/typescript/components/Modals/ChatProfileModal/DeleteChatModal.d.ts.map +1 -1
  105. package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts.map +1 -1
  106. package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts.map +1 -1
  107. package/lib/typescript/components/RoomComponents/ChatRoomItem.d.ts.map +1 -1
  108. package/lib/typescript/components/styled/DateLabel.d.ts.map +1 -1
  109. package/lib/typescript/components/styled/NewMessageLabel.d.ts.map +1 -1
  110. package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
  111. package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
  112. package/lib/typescript/helpers/getDataFromXml.d.ts.map +1 -1
  113. package/lib/typescript/helpers/insertMessageWithDelimiter.d.ts.map +1 -1
  114. package/lib/typescript/helpers/isUnresolvedSenderId.d.ts.map +1 -1
  115. package/lib/typescript/helpers/resolveLangSource.d.ts +30 -0
  116. package/lib/typescript/helpers/resolveLangSource.d.ts.map +1 -0
  117. package/lib/typescript/helpers/xmppUsername.d.ts +13 -0
  118. package/lib/typescript/helpers/xmppUsername.d.ts.map +1 -0
  119. package/lib/typescript/hooks/useChatWrapperInit.d.ts.map +1 -1
  120. package/lib/typescript/i18n/strings.d.ts.map +1 -1
  121. package/lib/typescript/i18n/useT.d.ts +1 -1
  122. package/lib/typescript/networking/stanzaHandlers.d.ts.map +1 -1
  123. package/lib/typescript/roomStore/persistence.d.ts.map +1 -1
  124. package/lib/typescript/version.d.ts +1 -1
  125. package/lib/typescript/version.d.ts.map +1 -1
  126. package/package.json +2 -1
  127. package/src/components/Header/HeaderRoomList.tsx +5 -1
  128. package/src/components/MainComponents/ChatWrapper.tsx +33 -0
  129. package/src/components/MainComponents/ReduxWrapper.tsx +18 -1
  130. package/src/components/MessageBubble/MessageTranslate.tsx +17 -12
  131. package/src/components/Modals/AttachSheet/AttachSheet.tsx +7 -3
  132. package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +11 -11
  133. package/src/components/Modals/ChatProfileModal/DeleteChatModal.tsx +9 -7
  134. package/src/components/Modals/NewChatModal/NewChatModal.tsx +7 -4
  135. package/src/components/Modals/ProfileHeader/ProfileHeader.tsx +11 -2
  136. package/src/components/RoomComponents/ChatRoomItem.tsx +47 -3
  137. package/src/components/styled/DateLabel.tsx +10 -3
  138. package/src/components/styled/NewMessageLabel.tsx +3 -1
  139. package/src/components/styled/SendInput.tsx +6 -8
  140. package/src/context/xmppProvider.tsx +7 -0
  141. package/src/helpers/getDataFromXml.ts +25 -1
  142. package/src/helpers/insertMessageWithDelimiter.ts +13 -0
  143. package/src/helpers/isUnresolvedSenderId.ts +9 -1
  144. package/src/helpers/resolveLangSource.ts +40 -0
  145. package/src/helpers/xmppUsername.ts +38 -0
  146. package/src/hooks/useChatWrapperInit.ts +6 -2
  147. package/src/i18n/strings.ts +120 -0
  148. package/src/i18n/useT.ts +1 -1
  149. package/src/networking/stanzaHandlers.ts +42 -67
  150. package/src/roomStore/persistence.ts +16 -0
  151. package/src/version.ts +3 -1
@@ -8,15 +8,14 @@ import {
8
8
  setComposing,
9
9
  setCurrentRoom,
10
10
  setRoomRole,
11
- updateRoom,
12
- mergeUsersSet,
13
11
  } from '../roomStore/roomsSlice';
14
- import { IRoom, RoomMember } from '../types/types';
12
+ import { IRoom } from '../types/types';
15
13
  import { createMessageFromXml } from '../helpers/createMessageFromXml';
16
14
  import { getDataFromXml } from '../helpers/getDataFromXml';
17
15
  import { setDeleteModal } from '../roomStore/chatSettingsSlice';
18
16
  import { messageNotificationManager } from '../utils/messageNotificationManager';
19
17
  import { transformCallLogMessage } from '../helpers/callLogMessage';
18
+ import { translateKey } from '../i18n/strings';
20
19
 
21
20
  // TO DO: we are thinking to refactor this code in the following way:
22
21
  // each stanza will be parsed for 'type'
@@ -121,13 +120,24 @@ const onRealtimeMessage = async (stanza: Element) => {
121
120
  }
122
121
  const room = state.rooms.rooms[roomJID];
123
122
  const roomName = room?.title || room?.name || '';
123
+ // Fallback when we don't have a display name for the sender. This is
124
+ // user-visible — it renders as the sender line in the in-app
125
+ // notification toast (see MessageNotificationContext's ToastRow:
126
+ // `{senderName}: {message.body}`) — so it goes through the static
127
+ // i18n table like any other UI caption. We're outside React here
128
+ // (stanza handler, not a component), so resolve the locale from the
129
+ // store directly and call `translateKey` instead of `useT()`.
130
+ const locale =
131
+ state.chatSettingStore.config?.i18n?.locale ||
132
+ state.chatSettingStore.langSource;
133
+ const overrides = state.chatSettingStore.config?.i18n?.strings;
124
134
  const senderName = [
125
135
  data.attrs.senderFirstName,
126
136
  data.attrs.senderLastName,
127
137
  ]
128
138
  .filter(Boolean)
129
139
  .join(' ')
130
- .trim() || 'New message';
140
+ .trim() || translateKey('notification.senderFallback', locale, overrides);
131
141
  messageNotificationManager.showNotification(
132
142
  message,
133
143
  roomName,
@@ -248,7 +258,7 @@ const onMessageHistory = async (stanza: any) => {
248
258
  // optimistic pending bubble the same way, instead of never carrying
249
259
  // an xmppId at all.
250
260
  if (forwardedMessage?.attrs?.id) {mergedAttrs.xmppId = forwardedMessage.attrs.id;}
251
- const rawMessage = await createMessageFromXml(
261
+ const positionalMessage = await createMessageFromXml(
252
262
  mergedAttrs,
253
263
  body,
254
264
  id,
@@ -264,6 +274,21 @@ const onMessageHistory = async (stanza: any) => {
264
274
  !!deleted
265
275
  );
266
276
 
277
+ // Translations ride on the archived stanza too (<translations> +
278
+ // <translate source>), but the positional parse above only reads
279
+ // <data> attrs + <body>, so every MAM-backfilled message lost them -
280
+ // translation looked dead on every room open. Parse the full stanza
281
+ // the way the realtime path does and carry ONLY those two fields over,
282
+ // so sender/xmppId resolution above (bug #41) stays exactly as is.
283
+ const parsedFull = await getDataFromXml(stanza).catch(() => undefined);
284
+ const rawMessage = {
285
+ ...positionalMessage,
286
+ ...(parsedFull?.translations
287
+ ? { translations: parsedFull.translations }
288
+ : {}),
289
+ ...(parsedFull?.langSource ? { langSource: parsedFull.langSource } : {}),
290
+ };
291
+
267
292
  // Same call-log transform as the realtime path, applied to archived
268
293
  // history so calls received while offline still render as log entries.
269
294
  const message = transformCallLogMessage(
@@ -363,68 +388,18 @@ const onChatInvite = async (stanza: Element, client: any) => {
363
388
 
364
389
  const onGetMembers = (stanza: Element) => {
365
390
  if (String(stanza.attrs?.id || '') !== 'roomMemberInfo') {return;}
366
-
367
- try {
368
- const queries: Element[] = stanza.getChildren('query') ?? [];
369
- const activities: Element[] = [];
370
- let roomJid = '';
371
- for (const q of queries) {
372
- if (!roomJid && q.attrs?.room) {roomJid = q.attrs.room;}
373
- const acts = q.getChildren('activity') ?? [];
374
- for (const a of acts) {activities.push(a);}
375
- }
376
-
377
- const jid = roomJid || store.getState().rooms.activeRoomJID;
378
- if (!jid || activities.length === 0) {return;}
379
-
380
- const existingRoom = store.getState().rooms.rooms[jid];
381
- const existingMembers: RoomMember[] = existingRoom?.roomMembers ?? [];
382
- const existingByJid = new Map<string, RoomMember>(
383
- existingMembers
384
- .filter((m): m is RoomMember & { jid: string } => !!m.jid)
385
- .map((m) => [m.jid, m])
386
- );
387
-
388
- const roomMembers: RoomMember[] = activities.map((a) => {
389
- const memberJid: string | undefined = a.attrs?.jid;
390
- const existing = memberJid ? existingByJid.get(memberJid) : undefined;
391
- // The activity stanza carries only the XMPP-side fields
392
- // (name/role/ban_status/last_active/jid). REST-loaded existing
393
- // members supply firstName/lastName/xmppUsername/_id; when there's
394
- // no REST match yet we leave those as empty strings.
395
- return {
396
- firstName: existing?.firstName ?? '',
397
- lastName: existing?.lastName ?? '',
398
- xmppUsername: existing?.xmppUsername ?? '',
399
- _id: existing?._id ?? '',
400
- ...existing,
401
- name: a.attrs?.name,
402
- role: a.attrs?.role,
403
- ban_status: a.attrs?.ban_status,
404
- last_active: Number(a.attrs?.last_active),
405
- jid: memberJid,
406
- };
407
- });
408
-
409
- store.dispatch(updateRoom({ jid, updates: { roomMembers } }));
410
-
411
- // Also feed the identity cache Message.tsx reads sender names from
412
- // (state.rooms.usersSet). Keyed by both the bare local part and the
413
- // full jid since a message's `user.id` can be either depending on
414
- // how it was parsed (see createUserNameFromSetUser).
415
- const usersSetUpdates: Record<string, RoomMember> = {};
416
- for (const member of roomMembers) {
417
- if (!member.jid) {continue;}
418
- const local = member.jid.split('@')[0];
419
- usersSetUpdates[local] = member;
420
- usersSetUpdates[member.jid] = member;
421
- }
422
- if (Object.keys(usersSetUpdates).length > 0) {
423
- store.dispatch(mergeUsersSet({ members: usersSetUpdates }));
424
- }
425
- } catch (err) {
426
- console.warn('onGetMembers parse failed', err);
427
- }
391
+ // Deliberately dispatches NOTHING — mirroring the web SDK, where this
392
+ // handler parses the activity list into a local and never touches the
393
+ // store. The activity stanza carries no firstName/lastName, and both of
394
+ // the old dispatches poisoned good REST data with empty-named entries:
395
+ // - updateRoom wholesale-replaced room.roomMembers (REST members carry
396
+ // no jid, so the existing-by-jid lookup always missed), blanking the
397
+ // ChatProfileModal member list;
398
+ // - mergeUsersSet overwrote REST-hydrated identity entries under the
399
+ // exact localpart key the sender-name resolver reads first, which is
400
+ // why most of usersSet ended up empty.
401
+ // REST (/chats/my → dispatchUsersSetFromRestItems + the roomMembers
402
+ // build in rooms.api.ts) is the one hydration path for both stores.
428
403
  };
429
404
 
430
405
  const onGetRoomInfo = (stanza: Element) => {
@@ -101,6 +101,22 @@ const PERSISTED_MESSAGE_FIELDS: (keyof IMessage)[] = [
101
101
  'originalName',
102
102
  'size',
103
103
  'langSource',
104
+ // `translations` MUST be here. A previous version of this list dropped
105
+ // it, on the theory that it mirrored the web SDK's persist contract —
106
+ // it doesn't: web's redux-persist config (web/src/roomStore/index.ts)
107
+ // has no per-field message whitelist at all, it persists whatever is in
108
+ // `room.messages` (capped to the last 50) and that includes
109
+ // `translations` verbatim. Field-picking is an RN-only mechanism, so
110
+ // "same as web" was never true for this key.
111
+ //
112
+ // Dropping it meant every cold start painted the cached transcript in
113
+ // the ORIGINAL language and only flipped to the translation once MAM
114
+ // re-sent the history a few seconds later (onMessageHistory re-parses
115
+ // <translations> off the wire) — visible on every launch, for every
116
+ // translated message, since the cache never had a translation to show
117
+ // in the first place. Persisting it here is what lets the very first
118
+ // paint already be translated, the way the live path already is.
119
+ 'translations',
104
120
  'callLog',
105
121
  // bug #39: without this, a message that was still in flight (no
106
122
  // server echo yet) at kill time comes back from disk indistinguishable
package/src/version.ts CHANGED
@@ -1 +1,3 @@
1
- export const ETHORA_CHAT_COMPONENT_VERSION = '25.7.5';
1
+ // Generated by scripts/sync-version.mjs on `npm version`.
2
+ // Edit package.json's version instead of this file.
3
+ export const ETHORA_CHAT_COMPONENT_VERSION = '26.8.2';