Skip to content

Commit f8a75a6

Browse files
committed
Adapt app to the Onyx store-based engine swap (PR 5)
Point at the PR 5 library (engine swap onto OnyxStore) and reconcile the two options it removes: - Drop `reuseConnection` from the SequentialQueue connect (the new registry does not pool connections). - Remove the remaining `waitForCollectionCallback` usages in the snapshot-mode connects that landed on main after the PR 1 migration. The PR 1/2/3 app migrations (waitForCollectionCallback, sourceValue, dependencies) are cherry-picked onto this branch since the PR 5 library stacks them. (cherry picked from commit 14395d8)
1 parent da61446 commit f8a75a6

7 files changed

Lines changed: 26 additions & 16 deletions

File tree

package-lock.json

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
"react-native-nitro-fetch": "1.5.4",
199199
"react-native-nitro-modules": "0.36.3",
200200
"react-native-nitro-sqlite": "9.6.0",
201-
"react-native-onyx": "3.0.95",
201+
"react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#86e4d308c3a3dc80c0d8eb55076feb61fbdf5be6",
202202
"react-native-pager-view": "8.0.0",
203203
"react-native-pdf": "7.0.2",
204204
"react-native-permissions": "^5.4.0",

src/libs/Network/SequentialQueue.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,6 @@ function flush(shouldResetPromise = true) {
512512
// Use connectWithoutView since this is for network queue and don't affect to any UI
513513
const connection = Onyx.connectWithoutView({
514514
key: ONYXKEYS.PERSISTED_REQUESTS,
515-
// We exceptionally opt out of reusing the connection here to avoid extra callback calls due to
516-
// an existing connection already made in PersistedRequests.ts.
517-
reuseConnection: false,
518515
callback: () => {
519516
Log.info('[SequentialQueue] PERSISTED_REQUESTS loaded, starting process()', false, {
520517
requestsLength: getAllPersistedRequests().length,

tests/actions/IOU/MoneyRequestSettersTest.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,9 @@ describe('actions/IOU', () => {
719719
resetDraftTransactionsCustomUnit(undefined);
720720
await waitForBatchedUpdates();
721721
const allDraftTransactions = await getOnyxValue(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT);
722-
// Assuming there are no draft transactions, this should be undefined or an empty object
723-
expect(allDraftTransactions).toBeUndefined();
722+
// Post-init, a known-but-empty collection resolves to the frozen `{}` (the legacy
723+
// `undefined`-for-empty-collection shim was removed in Onyx).
724+
expect(allDraftTransactions).toEqual({});
724725
});
725726
it('should reset custom unit for a transaction', async () => {
726727
const transactionID = 'transaction_reset_001';

tests/actions/IOU/RequestMoneyTest.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,9 @@ describe('actions/IOU', () => {
404404
Onyx.disconnect(connection);
405405

406406
// Snapshot data shouldn't be updated optimistically for requestMoney when the current search query type is invoice.
407-
expect(snapshotData).toBeUndefined();
407+
// Post-init, a known-but-empty collection resolves to the frozen `{}` (the legacy
408+
// `undefined`-for-empty-collection shim was removed in Onyx).
409+
expect(snapshotData).toEqual({});
408410
resolve();
409411
},
410412
});

tests/actions/ReportTest.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5251,7 +5251,10 @@ describe('actions/Report', () => {
52515251

52525252
const reportsCollectionAfter = await getOnyxValue(`${ONYXKEYS.COLLECTION.REPORT}`);
52535253

5254-
expect(reportsCollectionAfter).toBeUndefined();
5254+
// Post-init, a known-but-empty collection resolves to the frozen `{}` (the legacy
5255+
// `undefined`-for-empty-collection shim was removed in Onyx). What we want to assert
5256+
// here is that no report was created — the collection has zero members.
5257+
expect(reportsCollectionAfter).toEqual({});
52555258
});
52565259
});
52575260

tests/actions/TransactionEditTest.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ describe('actions/TransactionEdit', () => {
7676

7777
const backups = await getOnyxValue(`${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}`);
7878

79-
expect(backups).toBeUndefined();
79+
// Post-init, a known-but-empty collection resolves to the frozen `{}` (the legacy
80+
// `undefined`-for-empty-collection shim was removed in Onyx).
81+
expect(backups).toEqual({});
8082
});
8183
});
8284

@@ -136,7 +138,9 @@ describe('actions/TransactionEdit', () => {
136138

137139
const transactions = await getOnyxValue(`${ONYXKEYS.COLLECTION.TRANSACTION}`);
138140

139-
expect(transactions).toBeUndefined();
141+
// Post-init, a known-but-empty collection resolves to the frozen `{}` (the legacy
142+
// `undefined`-for-empty-collection shim was removed in Onyx).
143+
expect(transactions).toEqual({});
140144
});
141145
});
142146

0 commit comments

Comments
 (0)