Prep work before new revision for #4694.#4892
Merged
gnprice merged 21 commits intozulip:masterfrom Jul 16, 2021
Merged
Conversation
Greg confirms that `false` would have been treated the same way as zero: zulip#4694 (comment) The documented thing to do is to pass a number, so, do that: zulip#4694 (comment).
And, since that leaves us with `.reduce`s and `.reduceRight`s being done on empty arrays (which is pointless), drop those and use the `initialValue`s that had been passed to them.
…or`. So it's easier to inline `stateIterator`, which we'll do soon.
So it'll be easier to inline `stateIterator`, which we'll do soon.
We don't reassign these.
…rn`. None of these logs are actually active in production, but we'd like to change that soon, since they might help us discover unknown problems with storage. They're not active for two reasons: - The ones in `autoRehydrate` are behind a check for `config.log`, which we haven't been passing (we'll change that soon) - The others are behind a check for whether we're running in production or not (we'll change that soon) Since we're looking to dissolve or replace redux-persist, we feel comfortable making this kind of project-specific change.
This wasn't being logged anyway, since we haven't been passing `config.log` with the `autoRehydrate` call so far. But it's something that would get logged when things work as expected, so it'd be really noisy. If someone needs to log stuff for debugging, they'll want to find their own targeted logs to use anyway.
As we said we'd do in a recent commit.
We're working with unaltered state from memory, which should be shaped just like `GlobalState`. If a whole substate is undefined, it's not because redux-persist made it so. Still, `AsyncStorage.setItem` won't want anything other than a string [1]. In particular, we might end up giving it `undefined` if the value straight from Redux were `undefined`; I expect `serializer(undefined)` would give `undefined` because we serialize with JSON, and `JSON.stringify(undefined)` gives `undefined`. So, add a check to `reduxTypes` that `GlobalState` doesn't allow `undefined` at any of its keys. Also, if `AsyncStorage` does run into a problem, then redux-persist's function `warnIfSetError` should give us a console warning. The previous behavior of silently doing nothing when a value is `undefined` seems worse than that. [1] https://react-native-async-storage.github.io/async-storage/docs/api#setitem
Like we did for `removeItem` in 1d8ef1b. As in that case, grow the libdef for @react-native-community/async-storage, with the method suggested at the top: ``` // All definitions taken directly from: // @react-native-community/async-storage/lib/AsyncStorage.js ```
21ddc25 to
9027646
Compare
Member
|
Looks good, thanks! Merging. |
Contributor
Author
|
Thanks for the review! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #4694