From a73c5356a915f1b5b10e0d14fb74d10b5cc3f654 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Fri, 4 Aug 2023 13:46:04 -0400 Subject: [PATCH] use new lastUpdateID to do a quick reconnect --- .../backgroundRefresh/index.android.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/libs/Notification/PushNotification/backgroundRefresh/index.android.js b/src/libs/Notification/PushNotification/backgroundRefresh/index.android.js index cf482e72126a..ac9822dd04dd 100644 --- a/src/libs/Notification/PushNotification/backgroundRefresh/index.android.js +++ b/src/libs/Notification/PushNotification/backgroundRefresh/index.android.js @@ -1,5 +1,20 @@ +import Onyx from 'react-native-onyx'; import * as App from '../../../actions/App'; import Visibility from '../../../Visibility'; +import ONYXKEYS from '../../../../ONYXKEYS'; + +function getLastOnyxUpdateID() { + return new Promise((resolve) => { + const connectionID = Onyx.connect({ + key: ONYXKEYS.ONYX_UPDATES.LAST_UPDATE_ID, + callback: (lastUpdateID) => { + Onyx.disconnect(connectionID); + resolve(lastUpdateID); + }, + }); + }); +} + /** * Runs our reconnectApp action if the app is in the background. * @@ -11,5 +26,5 @@ export default function backgroundRefresh() { return; } - App.reconnectApp(); + getLastOnyxUpdateID().then((lastUpdateID) => App.reconnectApp(lastUpdateID)); }