Improve async workflow in authenticate.js
This commit is contained in:
parent
8e3c6b14d9
commit
c78fcda912
|
@ -53,19 +53,21 @@ const AuthenticateJsx = ({navigation}) => {
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const loginCallback = async () => {
|
const loginCallback = () => {
|
||||||
const profileJSON = JSON.stringify(TEST_PROFILE);
|
const initialization = [
|
||||||
|
[ "@user_profile", JSON.stringify(TEST_PROFILE) ],
|
||||||
|
[
|
||||||
|
"@user_notifications",
|
||||||
|
JSON.stringify({
|
||||||
|
unread: false,
|
||||||
|
memory: [{ id: 1 }, { id: 2 }],
|
||||||
|
})
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
// TODO: Should fetch initial notifications to prevent bugging a newly
|
AsyncStorage.multiSet(initialization).then(() => {
|
||||||
// logged in user about the notifications already on their account
|
navigation.navigate("Feed");
|
||||||
const notificationsJSON = JSON.stringify({
|
|
||||||
unread: false,
|
|
||||||
memory: [{ id: 1 }, { id: 2 }],
|
|
||||||
});
|
});
|
||||||
await AsyncStorage.setItem("@user_profile", profileJSON);
|
|
||||||
await AsyncStorage.setItem("@user_notifications", notificationsJSON);
|
|
||||||
|
|
||||||
navigation.navigate("Feed");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue