@@ -21,6 +21,7 @@ import { setRoasterData } from './redux/rosterDataSlice';
2121import store from './redux/store' ;
2222import { updateTheme , updateThemeColor } from './redux/themeColorDataSlice' ;
2323import { RECENTCHATSCREEN , REGISTERSCREEN } from './screens/constants' ;
24+ import { NOTIFICATION } from './helpers/constants' ;
2425
2526let 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