@@ -68,12 +68,10 @@ import {showReportActionNotification} from './Report';
6868import { resendValidateCode as sessionResendValidateCode } from './Session' ;
6969
7070let currentUserAccountID : number = CONST . DEFAULT_NUMBER_ID ;
71- let currentEmail = '' ;
7271Onyx . connect ( {
7372 key : ONYXKEYS . SESSION ,
7473 callback : ( value ) => {
7574 currentUserAccountID = value ?. accountID ?? CONST . DEFAULT_NUMBER_ID ;
76- currentEmail = value ?. email ?? '' ;
7775 } ,
7876} ) ;
7977
@@ -677,6 +675,7 @@ function isBlockedFromConcierge(blockedFromConciergeNVP: OnyxEntry<BlockedFromCo
677675function triggerNotifications < TKey extends OnyxKey > (
678676 onyxUpdates : Array < OnyxServerUpdate < TKey > > ,
679677 currentUserAccountIDParam : number ,
678+ currentUserEmail : string ,
680679 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
681680) {
682681 for ( const update of onyxUpdates ) {
@@ -689,8 +688,8 @@ function triggerNotifications<TKey extends OnyxKey>(
689688
690689 for ( const action of reportActions ) {
691690 if ( action ) {
692- // They aren't connected to a UI anywhere, it's OK to use currentEmail
693- showReportActionNotification ( reportID , action , currentUserAccountIDParam , currentEmail , reportAttributes ) ;
691+ // They aren't connected to a UI anywhere, it's OK to use currentUserEmail
692+ showReportActionNotification ( reportID , action , currentUserAccountIDParam , currentUserEmail , reportAttributes ) ;
694693 }
695694 }
696695 }
@@ -710,7 +709,7 @@ const isChannelMuted = (reportId: string, currentUserAccountIDParam: number) =>
710709 } ) ;
711710 } ) ;
712711
713- function playSoundForMessageType < TKey extends OnyxKey > ( pushJSON : Array < OnyxServerUpdate < TKey > > , currentUserAccountIDParam : number ) {
712+ function playSoundForMessageType < TKey extends OnyxKey > ( pushJSON : Array < OnyxServerUpdate < TKey > > , currentUserAccountIDParam : number , currentUserEmail : string ) {
714713 const reportActionsOnly = pushJSON . filter ( ( update ) => update . key ?. includes ( 'reportActions_' ) ) ;
715714 // "reportActions_5134363522480668" -> "5134363522480668"
716715 const reportID = reportActionsOnly
@@ -757,7 +756,7 @@ function playSoundForMessageType<TKey extends OnyxKey>(pushJSON: Array<OnyxServe
757756 }
758757
759758 // mention user
760- if ( 'html' in message && typeof message . html === 'string' && message . html . includes ( `<mention-user>@${ currentEmail } </mention-user>` ) ) {
759+ if ( 'html' in message && typeof message . html === 'string' && message . html . includes ( `<mention-user>@${ currentUserEmail } </mention-user>` ) ) {
761760 return playSound ( SOUNDS . ATTENTION ) ;
762761 }
763762
@@ -917,7 +916,7 @@ function initializePusherPingPong(currentUserAccountIDParam: number) {
917916 * Handles the newest events from Pusher where a single mega multipleEvents contains
918917 * an array of singular events all in one event
919918 */
920- function subscribeToUserEvents ( currentUserAccountIDParam : number , getReportAttributes ?: ( ) => ReportAttributesDerivedValue [ 'reports' ] | undefined ) {
919+ function subscribeToUserEvents ( currentUserAccountIDParam : number , currentUserEmail : string , getReportAttributes ?: ( ) => ReportAttributesDerivedValue [ 'reports' ] | undefined ) {
921920 // If we don't have the user's accountID yet (because the app isn't fully setup yet) we can't subscribe so return early
922921 if ( ! currentUserAccountIDParam ) {
923922 return ;
@@ -950,7 +949,7 @@ function subscribeToUserEvents(currentUserAccountIDParam: number, getReportAttri
950949 // See https://github.com/Expensify/App/issues/57961 for more details
951950 const debouncedPlaySoundForMessageType = debounce (
952951 ( pushJSONMessage : AnyOnyxServerUpdate [ ] ) => {
953- playSoundForMessageType ( pushJSONMessage , currentUserAccountIDParam ) ;
952+ playSoundForMessageType ( pushJSONMessage , currentUserAccountIDParam , currentUserEmail ) ;
954953 } ,
955954 CONST . TIMING . PLAY_SOUND_MESSAGE_DEBOUNCE_TIME ,
956955 { trailing : true } ,
@@ -972,7 +971,7 @@ function subscribeToUserEvents(currentUserAccountIDParam: number, getReportAttri
972971 }
973972
974973 const onyxUpdatePromise = Onyx . update ( pushJSON ) . then ( ( ) => {
975- triggerNotifications ( pushJSON , currentUserAccountIDParam , getReportAttributes ?.( ) ) ;
974+ triggerNotifications ( pushJSON , currentUserAccountIDParam , currentUserEmail , getReportAttributes ?.( ) ) ;
976975 } ) ;
977976
978977 // Return a promise when Onyx is done updating so that the OnyxUpdatesManager can properly apply all
0 commit comments