Skip to content

Commit f92103a

Browse files
MRN-900
1 parent 9f4f8f9 commit f92103a

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/SDK/index.js

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

src/SDK/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,10 @@ export const getUserSettings = async (iq = false) => {
523523

524524
export const updateNotificationSettings = async () => {
525525
let {
526+
data,
526527
data: { archive = 0, muteNotification = false, notificationSound = true, notificationVibrate = false },
527528
} = await SDK.getUserSettings();
529+
console.log('data ==>', JSON.stringify(data, null, 2));
528530
store.dispatch(toggleArchiveSetting(Number(archive)));
529531
store.dispatch(updateNotificationSetting({ muteNotification, notificationSound, notificationVibrate }));
530532
};

src/uikitMethods.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { setRoasterData } from './redux/rosterDataSlice';
2121
import store from './redux/store';
2222
import { updateTheme, updateThemeColor } from './redux/themeColorDataSlice';
2323
import { RECENTCHATSCREEN, REGISTERSCREEN } from './screens/constants';
24+
import { NOTIFICATION } from './helpers/constants';
2425

2526
let uiKitCallbackListenersVal = {},
2627
appInitialized = false,
@@ -68,18 +69,22 @@ export const mirrorflyNotificationHandler = async remoteMessage => {
6869
return;
6970
}
7071
if (notify?.statusCode === 200) {
71-
if (
72-
notify?.data?.type === 'receiveMessage' ||
73-
notify?.data?.msgType === 'groupCreated' ||
74-
notify?.data?.msgType === 'groupProfileUpdated'
75-
) {
72+
const { data = {}, data: { msgType, archiveStatus } = {} } = notify;
73+
notify.data.archiveSetting = getArchive();
74+
const isReceiveMessage = ['receiveMessage', 'carbonReceiveMessage'].includes(msgType);
75+
const archiveSettingAndStatus = archiveStatus ? !notify.data.archiveSetting : true;
76+
const isNotificationMessage =
77+
data.msgBody.message_type === NOTIFICATION.toLowerCase() &&
78+
data.msgBody.message === '2' &&
79+
getCurrentUserJid() === data.toUserJid;
80+
const isShowNotification = (archiveSettingAndStatus && isReceiveMessage) || isNotificationMessage;
81+
if (isShowNotification) {
7682
pushNotify(
7783
notify?.data?.msgId,
7884
getNotifyNickName(notify?.data),
7985
getNotifyMessage(notify?.data),
8086
notify?.data?.fromUserJid,
8187
);
82-
notify.data.archiveSetting = getArchive();
8388
store.dispatch(addRecentChatItem(notify?.data));
8489
store.dispatch(addChatMessageItem(notify?.data));
8590
}

0 commit comments

Comments
 (0)