Skip to content
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

fix resolution of AsyncStorage (#435) #437

Merged
merged 2 commits into from
Nov 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions app/worker/asyncStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ function convertErrors(errs) {
}

export const getSafeAsyncStorage = NativeModules => {
// Use RocksDB if available, then SQLite, then file storage.
// Changed Name of SQLite DB, to not conflict with AsyncStorage from RN repo
const RCTAsyncStorage =
NativeModules &&
(NativeModules.AsyncRocksDBStorage ||
NativeModules.RNC_AsyncSQLiteDBStorage ||
(NativeModules.RNC_AsyncSQLiteDBStorage ||
NativeModules.RNCAsyncStorage ||
NativeModules.PlatformLocalStorage ||
NativeModules.AsyncRocksDBStorage ||
NativeModules.AsyncSQLiteDBStorage ||
NativeModules.AsyncLocalStorage);

Expand All @@ -35,7 +35,8 @@ export const getSafeAsyncStorage = NativeModules => {
return new Promise((resolve, reject) => {
RCTAsyncStorage.multiGet([key], (errors, result) => {
// Unpack result to get value from [[key,value]]
const value = result && result[0] && result[0][1] ? result[0][1] : null;
const value =
result && result[0] && result[0][1] ? result[0][1] : null;
const errs = convertErrors(errors);
if (errs) {
reject(errs[0]);
Expand Down Expand Up @@ -90,7 +91,9 @@ export const getShowAsyncStorageFn = AsyncStorage => {
return async () => {
const keys = await AsyncStorage.getAllKeys();
if (keys && keys.length) {
const items = await Promise.all(keys.map(key => AsyncStorage.getItem(key)));
const items = await Promise.all(
keys.map(key => AsyncStorage.getItem(key)),
);
const table = {};
keys.forEach((key, index) => (table[key] = { content: items[index] }));
console.table(table);
Expand Down