@@ -66,12 +66,10 @@ import {showReportActionNotification} from './Report';
6666import { resendValidateCode as sessionResendValidateCode } from './Session' ;
6767
6868let currentUserAccountID : number = CONST . DEFAULT_NUMBER_ID ;
69- let currentEmail = '' ;
7069Onyx . connect ( {
7170 key : ONYXKEYS . SESSION ,
7271 callback : ( value ) => {
7372 currentUserAccountID = value ?. accountID ?? CONST . DEFAULT_NUMBER_ID ;
74- currentEmail = value ?. email ?? '' ;
7573 } ,
7674} ) ;
7775
@@ -619,6 +617,7 @@ function isBlockedFromConcierge(blockedFromConciergeNVP: OnyxEntry<BlockedFromCo
619617function triggerNotifications < TKey extends OnyxKey > (
620618 onyxUpdates : Array < OnyxServerUpdate < TKey > > ,
621619 currentUserAccountIDParam : number ,
620+ currentUserEmail : string ,
622621 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
623622) {
624623 for ( const update of onyxUpdates ) {
@@ -631,8 +630,8 @@ function triggerNotifications<TKey extends OnyxKey>(
631630
632631 for ( const action of reportActions ) {
633632 if ( action ) {
634- // They aren't connected to a UI anywhere, it's OK to use currentEmail
635- showReportActionNotification ( reportID , action , currentUserAccountIDParam , currentEmail , reportAttributes ) ;
633+ // They aren't connected to a UI anywhere, it's OK to use currentUserEmail
634+ showReportActionNotification ( reportID , action , currentUserAccountIDParam , currentUserEmail , reportAttributes ) ;
636635 }
637636 }
638637 }
@@ -652,7 +651,7 @@ const isChannelMuted = (reportId: string, currentUserAccountIDParam: number) =>
652651 } ) ;
653652 } ) ;
654653
655- function playSoundForMessageType < TKey extends OnyxKey > ( pushJSON : Array < OnyxServerUpdate < TKey > > , currentUserAccountIDParam : number ) {
654+ function playSoundForMessageType < TKey extends OnyxKey > ( pushJSON : Array < OnyxServerUpdate < TKey > > , currentUserAccountIDParam : number , currentUserEmail : string ) {
656655 const reportActionsOnly = pushJSON . filter ( ( update ) => update . key ?. includes ( 'reportActions_' ) ) ;
657656 // "reportActions_5134363522480668" -> "5134363522480668"
658657 const reportID = reportActionsOnly
@@ -699,7 +698,7 @@ function playSoundForMessageType<TKey extends OnyxKey>(pushJSON: Array<OnyxServe
699698 }
700699
701700 // mention user
702- if ( 'html' in message && typeof message . html === 'string' && message . html . includes ( `<mention-user>@${ currentEmail } </mention-user>` ) ) {
701+ if ( 'html' in message && typeof message . html === 'string' && message . html . includes ( `<mention-user>@${ currentUserEmail } </mention-user>` ) ) {
703702 return playSound ( SOUNDS . ATTENTION ) ;
704703 }
705704
@@ -859,7 +858,7 @@ function initializePusherPingPong(currentUserAccountIDParam: number) {
859858 * Handles the newest events from Pusher where a single mega multipleEvents contains
860859 * an array of singular events all in one event
861860 */
862- function subscribeToUserEvents ( currentUserAccountIDParam : number , getReportAttributes ?: ( ) => ReportAttributesDerivedValue [ 'reports' ] | undefined ) {
861+ function subscribeToUserEvents ( currentUserAccountIDParam : number , currentUserEmail : string , getReportAttributes ?: ( ) => ReportAttributesDerivedValue [ 'reports' ] | undefined ) {
863862 // 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
864863 if ( ! currentUserAccountIDParam ) {
865864 return ;
@@ -892,7 +891,7 @@ function subscribeToUserEvents(currentUserAccountIDParam: number, getReportAttri
892891 // See https://github.com/Expensify/App/issues/57961 for more details
893892 const debouncedPlaySoundForMessageType = debounce (
894893 ( pushJSONMessage : AnyOnyxServerUpdate [ ] ) => {
895- playSoundForMessageType ( pushJSONMessage , currentUserAccountIDParam ) ;
894+ playSoundForMessageType ( pushJSONMessage , currentUserAccountIDParam , currentUserEmail ) ;
896895 } ,
897896 CONST . TIMING . PLAY_SOUND_MESSAGE_DEBOUNCE_TIME ,
898897 { trailing : true } ,
@@ -914,7 +913,7 @@ function subscribeToUserEvents(currentUserAccountIDParam: number, getReportAttri
914913 }
915914
916915 const onyxUpdatePromise = Onyx . update ( pushJSON ) . then ( ( ) => {
917- triggerNotifications ( pushJSON , currentUserAccountIDParam , getReportAttributes ?.( ) ) ;
916+ triggerNotifications ( pushJSON , currentUserAccountIDParam , currentUserEmail , getReportAttributes ?.( ) ) ;
918917 } ) ;
919918
920919 // Return a promise when Onyx is done updating so that the OnyxUpdatesManager can properly apply all
0 commit comments