Skip to content

Commit 4c10a58

Browse files
committed
Merge branch 'main' into feature/sqlite-web
2 parents 3b11ba7 + 9b2638c commit 4c10a58

22 files changed

Lines changed: 970 additions & 637 deletions

API-INTERNAL.md

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ If the requested key is a collection, it will return an object with all the coll
8383
<ul>
8484
<li>Storage capacity errors: evicts data and retries the operation</li>
8585
<li>Invalid data errors: logs an alert and throws an error</li>
86+
<li>Non-retriable errors: logs an alert and resolves without retrying</li>
8687
<li>Other errors: retries the operation</li>
8788
</ul>
8889
</dd>
@@ -145,9 +146,6 @@ that this internal function allows passing an additional <code>mergeReplaceNullP
145146
Any existing collection members not included in the new data will not be removed.
146147
Retries on failure.</p>
147148
</dd>
148-
<dt><a href="#getCallbackToStateMapping">getCallbackToStateMapping()</a></dt>
149-
<dd><p>Getter - returns the callback to state mapping, useful in test environments.</p>
150-
</dd>
151149
<dt><a href="#clearOnyxUtilsInternals">clearOnyxUtilsInternals()</a></dt>
152150
<dd><p>Clear internal variables used in this file, useful in test environments.</p>
153151
</dd>
@@ -293,33 +291,12 @@ If the requested key is a collection, it will return an object with all the coll
293291
When a collection of keys change, search for any callbacks matching the collection key and trigger those callbacks
294292

295293
**Kind**: global function
296-
297-
* [keysChanged()](#keysChanged)
298-
* [~isSubscribedToCollectionKey](#keysChanged..isSubscribedToCollectionKey)
299-
* [~isSubscribedToCollectionMemberKey](#keysChanged..isSubscribedToCollectionMemberKey)
300-
301-
<a name="keysChanged..isSubscribedToCollectionKey"></a>
302-
303-
### keysChanged~isSubscribedToCollectionKey
304-
e.g. Onyx.connect({key: ONYXKEYS.COLLECTION.REPORT, callback: ...});
305-
306-
**Kind**: inner constant of [<code>keysChanged</code>](#keysChanged)
307-
<a name="keysChanged..isSubscribedToCollectionMemberKey"></a>
308-
309-
### keysChanged~isSubscribedToCollectionMemberKey
310-
e.g. Onyx.connect({key: `${ONYXKEYS.COLLECTION.REPORT}{reportID}`, callback: ...});
311-
312-
**Kind**: inner constant of [<code>keysChanged</code>](#keysChanged)
313294
<a name="keyChanged"></a>
314295

315296
## keyChanged()
316297
When a key change happens, search for any callbacks matching the key or collection key and trigger those callbacks
317298

318299
**Kind**: global function
319-
**Example**
320-
```js
321-
keyChanged(key, value, subscriber => subscriber.initWithStoredValues === false)
322-
```
323300
<a name="sendDataToConnection"></a>
324301

325302
## sendDataToConnection()
@@ -344,6 +321,7 @@ Remove a key from Onyx and update the subscribers
344321
Handles storage operation failures based on the error type:
345322
- Storage capacity errors: evicts data and retries the operation
346323
- Invalid data errors: logs an alert and throws an error
324+
- Non-retriable errors: logs an alert and resolves without retrying
347325
- Other errors: retries the operation
348326

349327
**Kind**: global function
@@ -522,12 +500,6 @@ Retries on failure.
522500
| params.collection | Object collection keyed by individual collection member keys and values |
523501
| retryAttempt | retry attempt |
524502

525-
<a name="getCallbackToStateMapping"></a>
526-
527-
## getCallbackToStateMapping()
528-
Getter - returns the callback to state mapping, useful in test environments.
529-
530-
**Kind**: global function
531503
<a name="clearOnyxUtilsInternals"></a>
532504

533505
## clearOnyxUtilsInternals()

API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ applied in the order they were called. Note: `Onyx.set()` calls do not work this
177177
**Example**
178178
```js
179179
Onyx.merge(ONYXKEYS.EMPLOYEE_LIST, ['Joe']); // -> ['Joe']
180-
Onyx.merge(ONYXKEYS.EMPLOYEE_LIST, ['Jack']); // -> ['Joe', 'Jack']
180+
Onyx.merge(ONYXKEYS.EMPLOYEE_LIST, ['Jack']); // -> ['Jack']
181181
Onyx.merge(ONYXKEYS.POLICY, {id: 1}); // -> {id: 1}
182182
Onyx.merge(ONYXKEYS.POLICY, {name: 'My Workspace'}); // -> {id: 1, name: 'My Workspace'}
183183
```

lib/Onyx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function multiSet(data: OnyxMultiSetInput): Promise<void> {
183183
*
184184
* @example
185185
* Onyx.merge(ONYXKEYS.EMPLOYEE_LIST, ['Joe']); // -> ['Joe']
186-
* Onyx.merge(ONYXKEYS.EMPLOYEE_LIST, ['Jack']); // -> ['Joe', 'Jack']
186+
* Onyx.merge(ONYXKEYS.EMPLOYEE_LIST, ['Jack']); // -> ['Jack']
187187
* Onyx.merge(ONYXKEYS.POLICY, {id: 1}); // -> {id: 1}
188188
* Onyx.merge(ONYXKEYS.POLICY, {name: 'My Workspace'}); // -> {id: 1, name: 'My Workspace'}
189189
*/

lib/OnyxConnectionManager.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,26 +115,21 @@ class OnyxConnectionManager {
115115
* according to their purpose and effect they produce in the Onyx connection.
116116
*/
117117
private generateConnectionID<TKey extends OnyxKey>(connectOptions: ConnectOptions<TKey>): string {
118-
const {key, initWithStoredValues, reuseConnection, waitForCollectionCallback} = connectOptions;
118+
const {key, reuseConnection, waitForCollectionCallback} = connectOptions;
119119

120120
// The current session ID is appended to the connection ID so we can have different connections
121121
// after an `Onyx.clear()` operation.
122122
let suffix = `,sessionID=${this.sessionID}`;
123123

124124
// We will generate a unique ID in any of the following situations:
125125
// - `reuseConnection` is `false`. That means the subscriber explicitly wants the connection to not be reused.
126-
// - `initWithStoredValues` is `false`. This flag changes the subscription flow when set to `false`, so the connection can't be reused.
127126
// - `key` is a collection key AND `waitForCollectionCallback` is `undefined/false`. This combination needs a new connection at every subscription
128127
// in order to send all the collection entries, so the connection can't be reused.
129-
if (
130-
reuseConnection === false ||
131-
initWithStoredValues === false ||
132-
(OnyxKeys.isCollectionKey(key) && (waitForCollectionCallback === undefined || waitForCollectionCallback === false))
133-
) {
128+
if (reuseConnection === false || (OnyxKeys.isCollectionKey(key) && (waitForCollectionCallback === undefined || waitForCollectionCallback === false))) {
134129
suffix += `,uniqueID=${Str.guid()}`;
135130
}
136131

137-
return `onyxKey=${key},initWithStoredValues=${initWithStoredValues ?? true},waitForCollectionCallback=${waitForCollectionCallback ?? false}${suffix}`;
132+
return `onyxKey=${key},waitForCollectionCallback=${waitForCollectionCallback ?? false}${suffix}`;
138133
}
139134

140135
/**

lib/OnyxSnapshotCache.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,13 @@ class OnyxSnapshotCache {
5858
* according to their purpose and effect they produce in the useOnyx hook behavior:
5959
*
6060
* - `selector`: Different selectors produce different results, so each selector needs its own cache entry
61-
* - `initWithStoredValues`: This flag changes the initial loading behavior and affects the returned fetch status
6261
*
6362
* Other options like `reuseConnection` don't affect the data transformation
6463
* or timing behavior of getSnapshot, so they're excluded from the cache key for better cache hit rates.
6564
*/
66-
registerConsumer<TKey extends OnyxKey, TReturnValue>(options: Pick<UseOnyxOptions<TKey, TReturnValue>, 'selector' | 'initWithStoredValues'>): string {
65+
registerConsumer<TKey extends OnyxKey, TReturnValue>(options: Pick<UseOnyxOptions<TKey, TReturnValue>, 'selector'>): string {
6766
const selectorID = options?.selector ? this.getSelectorID(options.selector) : 'no_selector';
68-
69-
// Create options hash without expensive JSON.stringify
70-
const initWithStoredValues = options?.initWithStoredValues ?? true;
71-
const cacheKey = `${selectorID}_${initWithStoredValues}`;
67+
const cacheKey = String(selectorID);
7268

7369
// Increment reference count for this cache key
7470
const currentCount = this.cacheKeyRefCounts.get(cacheKey) || 0;

0 commit comments

Comments
 (0)