@@ -67,14 +67,6 @@ import {openOldDotLink} from './Link';
6767import { showReportActionNotification } from './Report' ;
6868import { resendValidateCode as sessionResendValidateCode } from './Session' ;
6969
70- let currentUserAccountID : number = CONST . DEFAULT_NUMBER_ID ;
71- Onyx . connect ( {
72- key : ONYXKEYS . SESSION ,
73- callback : ( value ) => {
74- currentUserAccountID = value ?. accountID ?? CONST . DEFAULT_NUMBER_ID ;
75- } ,
76- } ) ;
77-
7870type DomainOnyxUpdate =
7971 | OnyxUpdate < `${typeof ONYXKEYS . COLLECTION . DOMAIN } ${string } `>
8072 | OnyxUpdate < `${typeof ONYXKEYS . COLLECTION . DOMAIN_PENDING_ACTIONS } ${string } `>
@@ -674,7 +666,7 @@ function isBlockedFromConcierge(blockedFromConciergeNVP: OnyxEntry<BlockedFromCo
674666
675667function triggerNotifications < TKey extends OnyxKey > (
676668 onyxUpdates : Array < OnyxServerUpdate < TKey > > ,
677- currentUserAccountIDParam : number ,
669+ currentUserAccountID : number ,
678670 currentUserEmail : string ,
679671 reportAttributes ?: ReportAttributesDerivedValue [ 'reports' ] ,
680672) {
@@ -689,27 +681,27 @@ function triggerNotifications<TKey extends OnyxKey>(
689681 for ( const action of reportActions ) {
690682 if ( action ) {
691683 // They aren't connected to a UI anywhere, it's OK to use currentUserEmail
692- showReportActionNotification ( reportID , action , currentUserAccountIDParam , currentUserEmail , reportAttributes ) ;
684+ showReportActionNotification ( reportID , action , currentUserAccountID , currentUserEmail , reportAttributes ) ;
693685 }
694686 }
695687 }
696688}
697689
698- const isChannelMuted = ( reportId : string , currentUserAccountIDParam : number ) =>
690+ const isChannelMuted = ( reportId : string , currentUserAccountID : number ) =>
699691 new Promise ( ( resolve ) => {
700692 // We use `connectWithoutView` here since this connection is non-reactive in nature.
701693 const connection = Onyx . connectWithoutView ( {
702694 key : `${ ONYXKEYS . COLLECTION . REPORT } ${ reportId } ` ,
703695 callback : ( report ) => {
704696 Onyx . disconnect ( connection ) ;
705- const notificationPreference = report ?. participants ?. [ currentUserAccountIDParam ] ?. notificationPreference ;
697+ const notificationPreference = report ?. participants ?. [ currentUserAccountID ] ?. notificationPreference ;
706698
707699 resolve ( ! notificationPreference || notificationPreference === CONST . REPORT . NOTIFICATION_PREFERENCE . MUTE || ReportUtils . isHiddenForCurrentUser ( notificationPreference ) ) ;
708700 } ,
709701 } ) ;
710702 } ) ;
711703
712- function playSoundForMessageType < TKey extends OnyxKey > ( pushJSON : Array < OnyxServerUpdate < TKey > > , currentUserAccountIDParam : number , currentUserEmail : string ) {
704+ function playSoundForMessageType < TKey extends OnyxKey > ( pushJSON : Array < OnyxServerUpdate < TKey > > , currentUserAccountID : number , currentUserEmail : string ) {
713705 const reportActionsOnly = pushJSON . filter ( ( update ) => update . key ?. includes ( 'reportActions_' ) ) ;
714706 // "reportActions_5134363522480668" -> "5134363522480668"
715707 const reportID = reportActionsOnly
@@ -720,7 +712,7 @@ function playSoundForMessageType<TKey extends OnyxKey>(pushJSON: Array<OnyxServe
720712 return ;
721713 }
722714
723- isChannelMuted ( reportID , currentUserAccountIDParam ) . then ( ( isSoundMuted ) => {
715+ isChannelMuted ( reportID , currentUserAccountID ) . then ( ( isSoundMuted ) => {
724716 if ( isSoundMuted ) {
725717 return ;
726718 }
@@ -799,13 +791,13 @@ function playSoundForMessageType<TKey extends OnyxKey>(pushJSON: Array<OnyxServe
799791let pongHasBeenMissed = false ;
800792let lastPingSentTimestamp = Date . now ( ) ;
801793let lastPongReceivedTimestamp = Date . now ( ) ;
802- function subscribeToPusherPong ( currentUserAccountIDParam : number ) {
794+ function subscribeToPusherPong ( currentUserAccountID : number ) {
803795 // If there is no user accountID yet (because the app isn't fully setup yet), the channel can't be subscribed to so return early
804- if ( ! currentUserAccountIDParam ) {
796+ if ( ! currentUserAccountID ) {
805797 return ;
806798 }
807799
808- PusherUtils . subscribeToPrivateUserChannelEvent ( Pusher . TYPE . PONG , currentUserAccountIDParam . toString ( ) , ( pushJSON ) => {
800+ PusherUtils . subscribeToPrivateUserChannelEvent ( Pusher . TYPE . PONG , currentUserAccountID . toString ( ) , ( pushJSON ) => {
809801 Log . info ( `[Pusher PINGPONG] Received a PONG event from the server` , false , pushJSON ) ;
810802 lastPongReceivedTimestamp = Date . now ( ) ;
811803
@@ -879,7 +871,7 @@ function checkForLatePongReplies() {
879871
880872let pingPusherIntervalID : ReturnType < typeof setInterval > ;
881873let checkForLatePongRepliesIntervalID : ReturnType < typeof setInterval > ;
882- function initializePusherPingPong ( currentUserAccountIDParam : number ) {
874+ function initializePusherPingPong ( currentUserAccountID : number ) {
883875 // Only run the ping pong from the leader client
884876 if ( ! ActiveClientManager . isClientTheLeader ( ) ) {
885877 Log . info ( "[Pusher PINGPONG] Not starting PING PONG because this instance isn't the leader client" ) ;
@@ -890,7 +882,7 @@ function initializePusherPingPong(currentUserAccountIDParam: number) {
890882
891883 // Subscribe to the pong event from Pusher. Unfortunately, there is no way of knowing when the client is actually subscribed
892884 // so there could be a little delay before the client is actually listening to this event.
893- subscribeToPusherPong ( currentUserAccountIDParam ) ;
885+ subscribeToPusherPong ( currentUserAccountID ) ;
894886
895887 // If things are initializing again (which is fine because it will reinitialize each time Pusher authenticates), clear the old intervals
896888 if ( pingPusherIntervalID ) {
@@ -916,15 +908,15 @@ function initializePusherPingPong(currentUserAccountIDParam: number) {
916908 * Handles the newest events from Pusher where a single mega multipleEvents contains
917909 * an array of singular events all in one event
918910 */
919- function subscribeToUserEvents ( currentUserAccountIDParam : number , currentUserEmail : string , getReportAttributes ?: ( ) => ReportAttributesDerivedValue [ 'reports' ] | undefined ) {
911+ function subscribeToUserEvents ( currentUserAccountID : number , currentUserEmail : string , getReportAttributes ?: ( ) => ReportAttributesDerivedValue [ 'reports' ] | undefined ) {
920912 // 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
921- if ( ! currentUserAccountIDParam ) {
913+ if ( ! currentUserAccountID ) {
922914 return ;
923915 }
924916
925917 // Handles the mega multipleEvents from Pusher which contains an array of single events.
926918 // Each single event is passed to PusherUtils in order to trigger the callbacks for that event
927- PusherUtils . subscribeToPrivateUserChannelEvent ( Pusher . TYPE . MULTIPLE_EVENTS , currentUserAccountIDParam . toString ( ) , ( pushJSON ) => {
919+ PusherUtils . subscribeToPrivateUserChannelEvent ( Pusher . TYPE . MULTIPLE_EVENTS , currentUserAccountID . toString ( ) , ( pushJSON ) => {
928920 const pushEventData = pushJSON ;
929921 // If this is not the main client, we shouldn't process any data received from pusher.
930922 if ( ! ActiveClientManager . isClientTheLeader ( ) ) {
@@ -949,7 +941,7 @@ function subscribeToUserEvents(currentUserAccountIDParam: number, currentUserEma
949941 // See https://github.com/Expensify/App/issues/57961 for more details
950942 const debouncedPlaySoundForMessageType = debounce (
951943 ( pushJSONMessage : AnyOnyxServerUpdate [ ] ) => {
952- playSoundForMessageType ( pushJSONMessage , currentUserAccountIDParam , currentUserEmail ) ;
944+ playSoundForMessageType ( pushJSONMessage , currentUserAccountID , currentUserEmail ) ;
953945 } ,
954946 CONST . TIMING . PLAY_SOUND_MESSAGE_DEBOUNCE_TIME ,
955947 { trailing : true } ,
@@ -962,7 +954,7 @@ function subscribeToUserEvents(currentUserAccountIDParam: number, currentUserEma
962954 return SequentialQueue . getCurrentRequest ( ) . then ( ( ) => {
963955 // If we don't have the currentUserAccountID (user is logged out) or this is not the
964956 // main client we don't want to update Onyx with data from Pusher
965- if ( ! currentUserAccountIDParam ) {
957+ if ( ! currentUserAccountID ) {
966958 return ;
967959 }
968960 if ( ! ActiveClientManager . isClientTheLeader ( ) ) {
@@ -971,7 +963,7 @@ function subscribeToUserEvents(currentUserAccountIDParam: number, currentUserEma
971963 }
972964
973965 const onyxUpdatePromise = Onyx . update ( pushJSON ) . then ( ( ) => {
974- triggerNotifications ( pushJSON , currentUserAccountIDParam , currentUserEmail , getReportAttributes ?.( ) ) ;
966+ triggerNotifications ( pushJSON , currentUserAccountID , currentUserEmail , getReportAttributes ?.( ) ) ;
975967 } ) ;
976968
977969 // Return a promise when Onyx is done updating so that the OnyxUpdatesManager can properly apply all
@@ -987,7 +979,7 @@ function subscribeToUserEvents(currentUserAccountIDParam: number, currentUserEma
987979 return Promise . resolve ( ) ;
988980 } ) ;
989981
990- initializePusherPingPong ( currentUserAccountIDParam ) ;
982+ initializePusherPingPong ( currentUserAccountID ) ;
991983}
992984
993985/**
@@ -1232,13 +1224,13 @@ function updateTheme(theme: ValueOf<typeof CONST.THEME>, shouldGoBack = true) {
12321224/**
12331225 * Sets a custom status
12341226 */
1235- function updateCustomStatus ( currentUserAccountIDParam : number , status : Status ) {
1227+ function updateCustomStatus ( currentUserAccountID : number , status : Status ) {
12361228 const optimisticData : Array < OnyxUpdate < typeof ONYXKEYS . PERSONAL_DETAILS_LIST > > = [
12371229 {
12381230 onyxMethod : Onyx . METHOD . MERGE ,
12391231 key : ONYXKEYS . PERSONAL_DETAILS_LIST ,
12401232 value : {
1241- [ currentUserAccountIDParam ] : {
1233+ [ currentUserAccountID ] : {
12421234 status,
12431235 } ,
12441236 } ,
@@ -1255,13 +1247,13 @@ function updateCustomStatus(currentUserAccountIDParam: number, status: Status) {
12551247/**
12561248 * Clears the custom status
12571249 */
1258- function clearCustomStatus ( currentUserAccountIDParam : number ) {
1250+ function clearCustomStatus ( currentUserAccountID : number ) {
12591251 const optimisticData : Array < OnyxUpdate < typeof ONYXKEYS . PERSONAL_DETAILS_LIST > > = [
12601252 {
12611253 onyxMethod : Onyx . METHOD . MERGE ,
12621254 key : ONYXKEYS . PERSONAL_DETAILS_LIST ,
12631255 value : {
1264- [ currentUserAccountIDParam ] : {
1256+ [ currentUserAccountID ] : {
12651257 status : null , // Clearing the field
12661258 } ,
12671259 } ,
@@ -1365,7 +1357,7 @@ function setShouldShowBranchNameInTitle(value: boolean) {
13651357 Onyx . set ( ONYXKEYS . SHOULD_SHOW_BRANCH_NAME_IN_TITLE , value ) ;
13661358}
13671359
1368- function lockAccount ( accountID ? : number , domainAccountID ? : number , domainName ? : string ) {
1360+ function lockAccount ( currentUserAccountID : number , accountID : number | undefined , domainAccountID : number | undefined , domainName : string | undefined ) {
13691361 let domainOptimisticData : DomainOnyxUpdate [ ] = [ ] ;
13701362 let domainFailureData : DomainOnyxUpdate [ ] = [ ] ;
13711363 let domainSuccessData : DomainOnyxUpdate [ ] = [ ] ;
0 commit comments