Skip to content

Commit

Permalink
use new lastUpdateID to do a quick reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
arosiclair committed Aug 4, 2023
1 parent b38d73b commit a73c535
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -11,5 +26,5 @@ export default function backgroundRefresh() {
return;
}

App.reconnectApp();
getLastOnyxUpdateID().then((lastUpdateID) => App.reconnectApp(lastUpdateID));
}

0 comments on commit a73c535

Please sign in to comment.