Skip to content

Commit 6779317

Browse files
SDK update, edit message send icon fix
1 parent b2c8a3f commit 6779317

File tree

8 files changed

+75
-45
lines changed

8 files changed

+75
-45
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { mirrorflyInitialize, mirrorflyNotificationHandler, setAppConfig, setupC
1212

1313
setAppConfig({ appSchema: MIRRORFLY_RN });
1414

15+
console.debug = () => {};
16+
1517
if (process.env?.NODE_ENV === 'development') {
1618
require('./ReactotronConfig');
1719
}

src/SDK/index.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/ChatHeaderActions.js

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,23 @@ import {
1313
handleConversationClear,
1414
handleMessageDelete,
1515
handleMessageDeleteForEveryOne,
16+
handleUpdateBlockUser,
1617
isAnyMessageWithinLast30Seconds,
1718
isLocalUser,
1819
} from '../helpers/chatHelpers';
19-
import { resetMessageSelections } from '../redux/chatMessageDataSlice';
20-
import { setReplyMessage } from '../redux/draftSlice';
21-
import { getSelectedChatMessages, useBlockedStatus, useSelectedChatMessages } from '../redux/reduxHook';
20+
import { resetMessageSelections, toggleEditMessage } from '../redux/chatMessageDataSlice';
21+
import { setReplyMessage, setTextMessage } from '../redux/draftSlice';
22+
import {
23+
getSelectedChatMessages,
24+
getUserNameFromStore,
25+
useBlockedStatus,
26+
useSelectedChatMessages,
27+
} from '../redux/reduxHook';
2228
import { FORWARD_MESSSAGE_SCREEN, MESSAGE_INFO_SCREEN } from '../screens/constants';
2329
import commonStyles from '../styles/commonStyles';
2430
import { chatInputRef } from './ChatInput';
31+
import { MIX_BARE_JID } from '../helpers/constants';
32+
import { getStringSet } from '../localization/stringSet';
2533

2634
export const RenderMessageSelectionCount = ({ userId }) => {
2735
const filtered = useSelectedChatMessages(userId) || [];
@@ -58,6 +66,7 @@ export function RenderReplyIcon({ userId }) {
5866

5967
export const RenderDeleteIcon = ({ userId, chatUser }) => {
6068
const [modalContent, setModalContent] = React.useState(null);
69+
const stringSet = getStringSet();
6170

6271
const toggleModalContent = () => {
6372
setModalContent(null);
@@ -70,12 +79,15 @@ export const RenderDeleteIcon = ({ userId, chatUser }) => {
7079
setModalContent({
7180
visible: true,
7281
onRequestClose: toggleModalContent,
73-
title: 'Are you sure you want to delete selected Message?',
74-
noButton: 'CANCEL',
75-
yesButton: 'DELETE FOR ME',
82+
title:
83+
selectedMessages?.length > 1
84+
? stringSet.CHAT_SCREEN.DELETE_MULTIPLE_MESSAGE
85+
: stringSet.CHAT_SCREEN.DELETE_SINGLE_MESSAGE,
86+
noButton: stringSet.BUTTON_LABEL.CANCEL_BUTTON,
87+
yesButton: stringSet.CHAT_SCREEN.DELETE_FOR_ME,
7688
yesAction: handleMessageDelete(chatUser),
7789
...(deleteForEveryOne && {
78-
optionalButton: 'DELETE FOR EVERYONE',
90+
optionalButton: stringSet.CHAT_SCREEN.DELETE_FOR_EVERYONE,
7991
optionalAction: handleMessageDeleteForEveryOne(chatUser),
8092
}),
8193
});
@@ -124,6 +136,7 @@ export const RenderMenuItems = ({ userId, chatUser }) => {
124136
const filtered = useSelectedChatMessages(userId) || [];
125137
const blockedStaus = useBlockedStatus(userId);
126138
const [modalContent, setModalContent] = React.useState(null);
139+
const stringSet = getStringSet();
127140

128141
const toggleModalContent = () => {
129142
setModalContent(null);
@@ -138,9 +151,9 @@ export const RenderMenuItems = ({ userId, chatUser }) => {
138151
setModalContent({
139152
visible: true,
140153
onRequestClose: toggleModalContent,
141-
title: 'Are you sure you want to clear the chat?',
142-
noButton: 'No',
143-
yesButton: 'Yes',
154+
title: stringSet.POPUP_TEXT.ARE_YOU_SURE_YOU_WANT_TO_CLEAR_THE_CHAT,
155+
noButton: stringSet.BUTTON_LABEL.NO_BUTTON,
156+
yesButton: stringSet.BUTTON_LABEL.YES_BUTTON,
144157
yesAction: handleClearAction,
145158
});
146159
};
@@ -149,7 +162,7 @@ export const RenderMenuItems = ({ userId, chatUser }) => {
149162
RootNavigation.navigate(MESSAGE_INFO_SCREEN, { chatUser, msgId: filtered[0].msgId });
150163
handelResetMessageSelection(userId)();
151164
};
152-
/**
165+
153166
const handleEditMessage = () => {
154167
handelResetMessageSelection(userId)();
155168
dispatch(toggleEditMessage(filtered[0].msgId));
@@ -164,13 +177,16 @@ export const RenderMenuItems = ({ userId, chatUser }) => {
164177
setModalContent({
165178
visible: true,
166179
onRequestClose: toggleModalContent,
167-
title: `${blockedStaus ? 'Unblock' : 'Block'} ${getUserNameFromStore(userId)}`,
168-
noButton: 'CANCEL',
169-
yesButton: blockedStaus ? 'UNBLOCK' : 'BLOCK',
180+
title: `${
181+
blockedStaus ? stringSet.CHAT_SCREEN.UNBLOCK_LABEL : stringSet.CHAT_SCREEN.BLOCK_LABEL
182+
} ${getUserNameFromStore(userId)}`,
183+
noButton: stringSet.BUTTON_LABEL.CANCEL_BUTTON,
184+
yesButton: blockedStaus
185+
? stringSet.CHAT_SCREEN.UNBLOCK_LABEL.toUpperCase()
186+
: stringSet.CHAT_SCREEN.BLOCK_LABEL.toUpperCase(),
170187
yesAction: handleUpdateBlockUser(userId, blockedStaus ? 0 : 1, chatUser),
171188
});
172189
};
173-
*/
174190

175191
/**
176192
const toggleSearch = () => {
@@ -184,7 +200,7 @@ export const RenderMenuItems = ({ userId, chatUser }) => {
184200
filtered[0]?.recallStatus === 0
185201
) {
186202
menuItems.push({
187-
label: 'Copy',
203+
label: stringSet.CHAT_SCREEN.COPY_TEXT_MENU_LABEL,
188204
formatter: copyToClipboard(filtered, userId),
189205
});
190206
}
@@ -197,26 +213,24 @@ export const RenderMenuItems = ({ userId, chatUser }) => {
197213
filtered[0]?.recallStatus === 0
198214
) {
199215
menuItems.push({
200-
label: 'Message Info',
216+
label: stringSet.CHAT_SCREEN.MESSAGE_INFO,
201217
formatter: handleGoMessageInfoScreen,
202218
});
203219
const now = Date.now();
204220
if (
205221
now - filtered[0]?.timestamp <= config.editMessageTime &&
206222
(filtered[0]?.msgBody.message_type === 'text' || filtered[0]?.msgBody?.media?.caption)
207223
) {
208-
/**
209224
menuItems.push({
210-
label: 'Edit Message',
225+
label: stringSet.CHAT_SCREEN.EDIT_MESSAGE,
211226
formatter: handleEditMessage,
212227
});
213-
*/
214228
}
215229
}
216230

217231
if (!filtered.length) {
218232
menuItems.push({
219-
label: 'Clear Chat',
233+
label: stringSet.CHAT_SCREEN.CLEAR_CHAT,
220234
formatter: handleClear,
221235
});
222236
/**
@@ -227,14 +241,12 @@ export const RenderMenuItems = ({ userId, chatUser }) => {
227241
*/
228242
}
229243

230-
/**
231244
if (!filtered.length && !MIX_BARE_JID.test(chatUser)) {
232245
menuItems.push({
233-
label: blockedStaus ? 'Unblock' : 'Block',
246+
label: blockedStaus ? stringSet.CHAT_SCREEN.UNBLOCK_LABEL : stringSet.CHAT_SCREEN.BLOCK_LABEL,
234247
formatter: hadleBlockUser,
235248
});
236249
}
237-
*/
238250

239251
if (menuItems.length === 0) {
240252
return null;

src/components/ChatInput.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,15 @@ function ChatInput({ chatUser }) {
184184
}
185185

186186
// Set timeout to update typing status after 1000ms (adjust as needed)
187-
typingTimeoutRef.current = setTimeout(() => {}, config.typingStatusGoneWaitTime);
187+
typingTimeoutRef.current = setTimeout(() => {
188+
updateTypingGoneStatus(chatUser);
189+
}, config.typingStatusGoneWaitTime);
188190
};
189191

190192
const sendMessage = () => {
191193
updateTypingGoneStatus(chatUser);
192194
switch (true) {
193-
case Boolean(editMessageId):
195+
case Boolean(message.trim()) && Boolean(editMessageId):
194196
setMessage('');
195197
dispatch(toggleEditMessage(''));
196198
handleSendMsg({
@@ -397,12 +399,14 @@ function ChatInput({ chatUser }) {
397399
<AttachmentIcon color={themeColorPalatte.iconColor} />
398400
</IconButton>
399401
)}
400-
<IconButton
401-
containerStyle={styles.audioRecordIconWrapper}
402-
style={styles.audioRecordIcon}
403-
onPress={onStartRecord}>
404-
<MicIcon />
405-
</IconButton>
402+
{!editMessageId && (
403+
<IconButton
404+
containerStyle={styles.audioRecordIconWrapper}
405+
style={styles.audioRecordIcon}
406+
onPress={onStartRecord}>
407+
<MicIcon />
408+
</IconButton>
409+
)}
406410
</>
407411
);
408412
}, [message, isEmojiPickerShowing, themeColorPalatte]);
@@ -435,7 +439,7 @@ function ChatInput({ chatUser }) {
435439
};
436440

437441
const renderSendButton = React.useMemo(() => {
438-
const isMessage = originalMessage ? originalMessage !== message.trim() : Boolean(message.trim());
442+
const isMessage = message.trim() && originalMessage !== message.trim();
439443
const isAllowSendMessage = isMessage || Boolean(recordSecs) || isAudioRecording === audioRecord.STOPPED;
440444

441445
if (isAudioRecording === audioRecord.RECORDING) {
@@ -473,7 +477,7 @@ function ChatInput({ chatUser }) {
473477
<Text
474478
style={[commonStyles.mainTextColor, commonStyles.textDecorationLine, commonStyles.fontSize_15]}
475479
onPress={hadleBlockUser}>
476-
Unblock
480+
{stringSet.CHAT_SCREEN.UNBLOCK_LABEL}
477481
</Text>
478482
</Text>
479483
{modalContent && <AlertModal {...modalContent} />}

src/components/ChatMessage.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function ChatMessage({ chatUser, item, showNickName, label }) {
6969

7070
const onPress = () => {
7171
const messsageList = getChatMessages(userId);
72-
const isAnySelected = messsageList?.some?.(item => item.isSelected === 1);
72+
const isAnySelected = messsageList?.some?.(_item => _item.isSelected === 1);
7373
switch (true) {
7474
case isAnySelected:
7575
const selectData = {
@@ -95,6 +95,8 @@ function ChatMessage({ chatUser, item, showNickName, label }) {
9595
case message_type === 'locaiton':
9696
openLocationExternally(latitude, longitude);
9797
break;
98+
default:
99+
Keyboard.dismiss();
98100
}
99101
};
100102

src/localization/languages/ar.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@
8080
"CONTACT_CARD_INVITE_LABEL": "دعوة صديق",
8181
"UNBLOCK_LABEL": "إلغاء الحظر",
8282
"BLOCK_LABEL": "حاجز",
83-
"UNBLOCK_CHAT_INPUT_LABEL": "لقد قمت بحظر {nickName}."
83+
"UNBLOCK_CHAT_INPUT_LABEL": "لقد قمت بحظر {nickName}.",
84+
"EDIT_MESSAGE": "تحرير الرسالة",
85+
"MESSAGE_INFO": "معلومات الرسالة",
86+
"CLEAR_CHAT": "مسح الدردشة"
8487
},
8588
"FORWARD_SCREEN": {
8689
"FORWARD_HEADER_TITLE": "إعادة توجيه إلى...",
@@ -212,7 +215,8 @@
212215
"START_CHAT": "بدء محادثة",
213216
"LOG_OUT_HEADER_LABEL": "هل أنت متأكد أنك تريد تسجيل الخروج من التطبيق؟",
214217
"UNBLOCK_POPUP_LABEL": "إلغاء حظر {nickName}",
215-
"BLOCK_POPUP_LABEL": "حظر {nickName}"
218+
"BLOCK_POPUP_LABEL": "حظر {nickName}",
219+
"ARE_YOU_SURE_YOU_WANT_TO_CLEAR_THE_CHAT": "هل أنت متأكد أنك تريد مسح الدردشة؟"
216220
},
217221
"BUTTON_LABEL": {
218222
"NO_BUTTON": "لا",

src/localization/languages/en.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@
8080
"REPLY_CONTACT_TYPE": "Contact: {nickName}",
8181
"CONTACT_CARD_INVITE": "Invite",
8282
"CONTACT_CARD_VIEW": "View",
83-
"CONTACT_CARD_INVITE_LABEL": "Invite Friend"
83+
"CONTACT_CARD_INVITE_LABEL": "Invite Friend",
84+
"EDIT_MESSAGE": "Edit Message",
85+
"MESSAGE_INFO": "Message Info",
86+
"CLEAR_CHAT": "Clear Chat"
8487
},
8588
"FORWARD_SCREEN": {
8689
"FORWARD_HEADER_TITLE": "Forward to...",
@@ -212,7 +215,8 @@
212215
"START_CHAT": "Start Chat",
213216
"UNBLOCK_POPUP_LABEL": "Unblock {nickName}",
214217
"BLOCK_POPUP_LABEL": "Block {nickName}",
215-
"LOG_OUT_HEADER_LABEL": "Are you sure want to logout from the app?"
218+
"LOG_OUT_HEADER_LABEL": "Are you sure want to logout from the app?",
219+
"ARE_YOU_SURE_YOU_WANT_TO_CLEAR_THE_CHAT": "Are you sure you want to clear the chat?"
216220
},
217221
"BUTTON_LABEL": {
218222
"NO_BUTTON": "No",

src/redux/chatMessageDataSlice.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ const chatMessageDataSlice = createSlice({
3030
}
3131
});
3232
const userId = getUserIdFromJid(userJid);
33-
if (!Array.isArray(data)) return;
33+
if (!Array.isArray(data)) {
34+
return;
35+
}
3436
if (state[userId] && !forceUpdate) {
3537
// Merge existing messages with new ones
3638
state[userId] = removeDuplicates([...state[userId], ...data]);
@@ -54,7 +56,7 @@ const chatMessageDataSlice = createSlice({
5456
);
5557
},
5658
addChatMessageItem(state, action) {
57-
const { userJid, msgBody: { replyTo = '', msgId } = {} } = action.payload;
59+
const { userJid, msgBody: { replyTo = '' } = {}, msgId } = action.payload;
5860
const userId = getUserIdFromJid(userJid);
5961
if (replyTo && state[userId]) {
6062
const message = state[userId].find(item => item.msgId === replyTo);

0 commit comments

Comments
 (0)