@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.
- package/lib/commonjs/components/Header/HeaderRoomList.js +3 -1
- package/lib/commonjs/components/Header/HeaderRoomList.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatWrapper.js +25 -0
- package/lib/commonjs/components/MainComponents/ChatWrapper.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ReduxWrapper.js +24 -3
- package/lib/commonjs/components/MainComponents/ReduxWrapper.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/MessageTranslate.js +16 -7
- package/lib/commonjs/components/MessageBubble/MessageTranslate.js.map +1 -1
- package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js +7 -3
- package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +12 -10
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/DeleteChatModal.js +9 -7
- package/lib/commonjs/components/Modals/ChatProfileModal/DeleteChatModal.js.map +1 -1
- package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js +3 -3
- package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js +8 -1
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js +32 -2
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/commonjs/components/styled/DateLabel.js +10 -3
- package/lib/commonjs/components/styled/DateLabel.js.map +1 -1
- package/lib/commonjs/components/styled/NewMessageLabel.js +3 -1
- package/lib/commonjs/components/styled/NewMessageLabel.js.map +1 -1
- package/lib/commonjs/components/styled/SendInput.js +6 -6
- package/lib/commonjs/components/styled/SendInput.js.map +1 -1
- package/lib/commonjs/context/xmppProvider.js +7 -0
- package/lib/commonjs/context/xmppProvider.js.map +1 -1
- package/lib/commonjs/helpers/getDataFromXml.js +24 -1
- package/lib/commonjs/helpers/getDataFromXml.js.map +1 -1
- package/lib/commonjs/helpers/insertMessageWithDelimiter.js +13 -0
- package/lib/commonjs/helpers/insertMessageWithDelimiter.js.map +1 -1
- package/lib/commonjs/helpers/isUnresolvedSenderId.js +6 -1
- package/lib/commonjs/helpers/isUnresolvedSenderId.js.map +1 -1
- package/lib/commonjs/helpers/resolveLangSource.js +38 -0
- package/lib/commonjs/helpers/resolveLangSource.js.map +1 -0
- package/lib/commonjs/helpers/xmppUsername.js +39 -0
- package/lib/commonjs/helpers/xmppUsername.js.map +1 -0
- package/lib/commonjs/hooks/useChatWrapperInit.js +4 -2
- package/lib/commonjs/hooks/useChatWrapperInit.js.map +1 -1
- package/lib/commonjs/i18n/strings.js +120 -0
- package/lib/commonjs/i18n/strings.js.map +1 -1
- package/lib/commonjs/i18n/useT.js +1 -1
- package/lib/commonjs/networking/stanzaHandlers.js +41 -70
- package/lib/commonjs/networking/stanzaHandlers.js.map +1 -1
- package/lib/commonjs/roomStore/persistence.js +17 -1
- package/lib/commonjs/roomStore/persistence.js.map +1 -1
- package/lib/commonjs/version.js +3 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/components/Header/HeaderRoomList.js +3 -1
- package/lib/module/components/Header/HeaderRoomList.js.map +1 -1
- package/lib/module/components/MainComponents/ChatWrapper.js +26 -1
- package/lib/module/components/MainComponents/ChatWrapper.js.map +1 -1
- package/lib/module/components/MainComponents/ReduxWrapper.js +26 -5
- package/lib/module/components/MainComponents/ReduxWrapper.js.map +1 -1
- package/lib/module/components/MessageBubble/MessageTranslate.js +16 -7
- package/lib/module/components/MessageBubble/MessageTranslate.js.map +1 -1
- package/lib/module/components/Modals/AttachSheet/AttachSheet.js +7 -3
- package/lib/module/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +12 -10
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/DeleteChatModal.js +9 -7
- package/lib/module/components/Modals/ChatProfileModal/DeleteChatModal.js.map +1 -1
- package/lib/module/components/Modals/NewChatModal/NewChatModal.js +3 -3
- package/lib/module/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
- package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js +8 -1
- package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js.map +1 -1
- package/lib/module/components/RoomComponents/ChatRoomItem.js +33 -3
- package/lib/module/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/module/components/styled/DateLabel.js +10 -3
- package/lib/module/components/styled/DateLabel.js.map +1 -1
- package/lib/module/components/styled/NewMessageLabel.js +3 -1
- package/lib/module/components/styled/NewMessageLabel.js.map +1 -1
- package/lib/module/components/styled/SendInput.js +6 -6
- package/lib/module/components/styled/SendInput.js.map +1 -1
- package/lib/module/context/xmppProvider.js +7 -0
- package/lib/module/context/xmppProvider.js.map +1 -1
- package/lib/module/helpers/getDataFromXml.js +23 -1
- package/lib/module/helpers/getDataFromXml.js.map +1 -1
- package/lib/module/helpers/insertMessageWithDelimiter.js +13 -0
- package/lib/module/helpers/insertMessageWithDelimiter.js.map +1 -1
- package/lib/module/helpers/isUnresolvedSenderId.js +6 -1
- package/lib/module/helpers/isUnresolvedSenderId.js.map +1 -1
- package/lib/module/helpers/resolveLangSource.js +32 -0
- package/lib/module/helpers/resolveLangSource.js.map +1 -0
- package/lib/module/helpers/xmppUsername.js +35 -0
- package/lib/module/helpers/xmppUsername.js.map +1 -0
- package/lib/module/hooks/useChatWrapperInit.js +4 -2
- package/lib/module/hooks/useChatWrapperInit.js.map +1 -1
- package/lib/module/i18n/strings.js +120 -0
- package/lib/module/i18n/strings.js.map +1 -1
- package/lib/module/i18n/useT.js +1 -1
- package/lib/module/networking/stanzaHandlers.js +42 -71
- package/lib/module/networking/stanzaHandlers.js.map +1 -1
- package/lib/module/roomStore/persistence.js +17 -1
- package/lib/module/roomStore/persistence.js.map +1 -1
- package/lib/module/version.js +3 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/components/Header/HeaderRoomList.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatWrapper.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ReduxWrapper.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/MessageTranslate.d.ts.map +1 -1
- package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/DeleteChatModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/ChatRoomItem.d.ts.map +1 -1
- package/lib/typescript/components/styled/DateLabel.d.ts.map +1 -1
- package/lib/typescript/components/styled/NewMessageLabel.d.ts.map +1 -1
- package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
- package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
- package/lib/typescript/helpers/getDataFromXml.d.ts.map +1 -1
- package/lib/typescript/helpers/insertMessageWithDelimiter.d.ts.map +1 -1
- package/lib/typescript/helpers/isUnresolvedSenderId.d.ts.map +1 -1
- package/lib/typescript/helpers/resolveLangSource.d.ts +30 -0
- package/lib/typescript/helpers/resolveLangSource.d.ts.map +1 -0
- package/lib/typescript/helpers/xmppUsername.d.ts +13 -0
- package/lib/typescript/helpers/xmppUsername.d.ts.map +1 -0
- package/lib/typescript/hooks/useChatWrapperInit.d.ts.map +1 -1
- package/lib/typescript/i18n/strings.d.ts.map +1 -1
- package/lib/typescript/i18n/useT.d.ts +1 -1
- package/lib/typescript/networking/stanzaHandlers.d.ts.map +1 -1
- package/lib/typescript/roomStore/persistence.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/components/Header/HeaderRoomList.tsx +5 -1
- package/src/components/MainComponents/ChatWrapper.tsx +33 -0
- package/src/components/MainComponents/ReduxWrapper.tsx +18 -1
- package/src/components/MessageBubble/MessageTranslate.tsx +17 -12
- package/src/components/Modals/AttachSheet/AttachSheet.tsx +7 -3
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +11 -11
- package/src/components/Modals/ChatProfileModal/DeleteChatModal.tsx +9 -7
- package/src/components/Modals/NewChatModal/NewChatModal.tsx +7 -4
- package/src/components/Modals/ProfileHeader/ProfileHeader.tsx +11 -2
- package/src/components/RoomComponents/ChatRoomItem.tsx +47 -3
- package/src/components/styled/DateLabel.tsx +10 -3
- package/src/components/styled/NewMessageLabel.tsx +3 -1
- package/src/components/styled/SendInput.tsx +6 -8
- package/src/context/xmppProvider.tsx +7 -0
- package/src/helpers/getDataFromXml.ts +25 -1
- package/src/helpers/insertMessageWithDelimiter.ts +13 -0
- package/src/helpers/isUnresolvedSenderId.ts +9 -1
- package/src/helpers/resolveLangSource.ts +40 -0
- package/src/helpers/xmppUsername.ts +38 -0
- package/src/hooks/useChatWrapperInit.ts +6 -2
- package/src/i18n/strings.ts +120 -0
- package/src/i18n/useT.ts +1 -1
- package/src/networking/stanzaHandlers.ts +42 -67
- package/src/roomStore/persistence.ts +16 -0
- 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
|
|
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() || '
|
|
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
|
|
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
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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