-
-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for ZulipAsyncStorage.getItem
and .setItem
.
#4709
Add tests for ZulipAsyncStorage.getItem
and .setItem
.
#4709
Commits on Jun 3, 2021
-
MainTabsScreen [nfc]: Make it clear that
isPad
is iOS-only.Although it doesn't give a reason why, the `Platform` doc [1] is clear that `isPad` is iOS-only; we can expect it to be missing on Android. We'd love to know whether an Android user is on a tablet, but it seems `Platform` doesn't yet give us a way to do that. Until it does, or until we use something else that does, make it really clear that we're not getting accurate info on Android. [1] https://reactnative.dev/docs/platform#ispad-ios
Configuration menu - View commit details
-
Copy full SHA for 96b796b - Browse repository at this point
Copy the full SHA 96b796bView commit details -
ZulipAsyncStorage tests: Add tests for
setItem
.With a new mock for `TextCompressionModule`; we do that globally in case it's useful elsewhere. That module should have its own set of unit tests, if we plan to keep it; it looks like it doesn't yet.
Configuration menu - View commit details
-
Copy full SHA for 58bbee6 - Browse repository at this point
Copy the full SHA 58bbee6View commit details -
Configuration menu - View commit details
-
Copy full SHA for f9bbdd0 - Browse repository at this point
Copy the full SHA f9bbdd0View commit details -
ZulipAsyncStorage types: Better align .setItem/.getItem with AsyncSto…
…rage. Now, the type for the `callback` param matches what's in the libdef for `AsyncStorage`. I think the question mark in the `?(...) => Foo` syntax isn't what we'd normally choose, but `ZulipAsyncStorage` is a wrapper around `AsyncStorage` so it might as well match this detail. Also the callback in `getItem` wasn't being considered optional at all, and now it is, which it looks like our implementation expects.
Configuration menu - View commit details
-
Copy full SHA for b35aeb9 - Browse repository at this point
Copy the full SHA b35aeb9View commit details -
ZulipAsyncStorage: Pass null for error, not undefined, on .getItem su…
…ccess. `null` gets passed on `.setItem`'s success, so we might as well be consistent and do the same thing with `.getItem`. I'm starting to think that `.getItem` and `.setItem`'s callback-based interfaces can be trimmed away, and callers can exclusively use the returned Promise.
Configuration menu - View commit details
-
Copy full SHA for 21f12c8 - Browse repository at this point
Copy the full SHA 21f12c8View commit details -
ZulipAsyncStorage: Also call callback on
AsyncStorage.getItem
failure.A bug like this is another reason I'm continuing to think we should just not bother to maintain a callback-based interface, here and in `.setItem`, and just maintain the Promise-based interface. Before we vendored redux-persist, which is the home of these methods' only callers, this would have been trickier. But now it's easy to make those callers adapt to the Promise-based interface.
Configuration menu - View commit details
-
Copy full SHA for d945e45 - Browse repository at this point
Copy the full SHA d945e45View commit details -
Configuration menu - View commit details
-
Copy full SHA for e91d9a8 - Browse repository at this point
Copy the full SHA e91d9a8View commit details -
Configuration menu - View commit details
-
Copy full SHA for f46368f - Browse repository at this point
Copy the full SHA f46368fView commit details -
redux-persist [nfc]: Remove some inactive code paths we'll never use.
We don't and can't use `window.localStorage` [1], `window.sessionStorage` [2], or `localforage` [3]; those are (or they use) web APIs. So, trim all this stuff that's related to those out. I think I got it all, and no more; anyway, the app still runs, and storage seems to work fine. [1] https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage [2] https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage [3] https://github.com/localForage/localForage
Configuration menu - View commit details
-
Copy full SHA for 317e9ea - Browse repository at this point
Copy the full SHA 317e9eaView commit details -
redux-persist: Make early
return
explicit.It looks like the rest of this callback is only meant to run if there hasn't been an error. In practice, I think most of it wasn't running anyway, since there would have been an error like "TypeError: Cannot read property 'filter' of undefined" on the `allKeys.filter(...)` just below. Good to be explicit, though.
Configuration menu - View commit details
-
Copy full SHA for 3737f61 - Browse repository at this point
Copy the full SHA 3737f61View commit details -
redux-persist [nfc]: Stop using callbacks with
ZulipAsyncStorage.foo
.Instead, use these functions' returned Promises. This will let us drop ZulipAsyncStorage's callback-based interface, which will simplify its code. Done carefully to preserve the control flow.
Configuration menu - View commit details
-
Copy full SHA for a81847f - Browse repository at this point
Copy the full SHA a81847fView commit details -
ZulipAsyncStorage [nfc]: Drop support for passing callbacks.
This simplifies the code quite a bit.
Configuration menu - View commit details
-
Copy full SHA for 9fff76d - Browse repository at this point
Copy the full SHA 9fff76dView commit details -
reduxTypes: Mark
GlobalState
's properties as read-only.We already treat them as read-only everywhere except for one case, touched in this commit, where we've had to suppress several different Flow errors [0]. So, mark them as read-only with `$ReadOnly` [1]. Treating `GlobalState`'s properties as read-only (except for that one exceptional case) is likely to be very stable: we treat them as read-only because the Redux state is a tree of objects that are all treated as immutable; see the Redux docs [2] and our architecture doc [3]. [0] See Greg's comments on this at zulip#4709 (comment) [1] https://flow.org/en/docs/types/utilities/#toc-readonly [2] http://redux.js.org [3] ./docs/architecture.md
Configuration menu - View commit details
-
Copy full SHA for cd29cb9 - Browse repository at this point
Copy the full SHA cd29cb9View commit details -
Configuration menu - View commit details
-
Copy full SHA for df29833 - Browse repository at this point
Copy the full SHA df29833View commit details