From d86b4e5503e04bfc9a0776a07ef2304d69f6644d Mon Sep 17 00:00:00 2001 From: Ionatan Wiznia Date: Mon, 9 Sep 2024 16:16:33 +0200 Subject: [PATCH 1/2] ReconnectApp when we receive the reconnectApp event --- src/libs/Pusher/EventType.ts | 1 + src/libs/actions/User.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/libs/Pusher/EventType.ts b/src/libs/Pusher/EventType.ts index 89e8a0ca02600..f1f0592aeac64 100644 --- a/src/libs/Pusher/EventType.ts +++ b/src/libs/Pusher/EventType.ts @@ -10,5 +10,6 @@ export default { MULTIPLE_EVENTS: 'multipleEvents', MULTIPLE_EVENT_TYPE: { ONYX_API_UPDATE: 'onyxApiUpdate', + RECONNECT_APP: 'reconnectApp', }, } as const; diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 355dcf93338e2..0c35c4bee2f03 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -33,6 +33,7 @@ import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import playSound, {SOUNDS} from '@libs/Sound'; import playSoundExcludingMobile from '@libs/Sound/playSoundExcludingMobile'; import Visibility from '@libs/Visibility'; +import * as App from '@userActions/App'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -905,6 +906,13 @@ function subscribeToUserEvents() { return onyxUpdatePromise; }); }); + + // We have an event to reconnect the App. It is triggered when we detect that the user passed updateID + // is not in the DB + PusherUtils.subscribeToMultiEvent(Pusher.TYPE.MULTIPLE_EVENT_TYPE.RECONNECT_APP, () => { + App.reconnectApp(); + return Promise.resolve(); + }); } /** From 76095c49392675ccce82a9328ae3f1e46abac949 Mon Sep 17 00:00:00 2001 From: Ionatan Wiznia Date: Mon, 9 Sep 2024 16:35:48 +0200 Subject: [PATCH 2/2] Link import --- src/libs/actions/User.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 0c35c4bee2f03..ee578db1f84f7 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -33,7 +33,6 @@ import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import playSound, {SOUNDS} from '@libs/Sound'; import playSoundExcludingMobile from '@libs/Sound/playSoundExcludingMobile'; import Visibility from '@libs/Visibility'; -import * as App from '@userActions/App'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -44,6 +43,7 @@ import type OnyxPersonalDetails from '@src/types/onyx/PersonalDetails'; import type {Status} from '@src/types/onyx/PersonalDetails'; import type ReportAction from '@src/types/onyx/ReportAction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import * as App from './App'; import applyOnyxUpdatesReliably from './applyOnyxUpdatesReliably'; import * as Link from './Link'; import * as Report from './Report';