Improve async workflow in authenticate.js

This commit is contained in:
Nat 2021-04-03 04:29:54 -03:00
parent 8e3c6b14d9
commit c78fcda912
1 changed files with 13 additions and 11 deletions

View File

@ -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) ],
// TODO: Should fetch initial notifications to prevent bugging a newly [
// logged in user about the notifications already on their account "@user_notifications",
const notificationsJSON = JSON.stringify({ JSON.stringify({
unread: false, unread: false,
memory: [{ id: 1 }, { id: 2 }], memory: [{ id: 1 }, { id: 2 }],
}); })
await AsyncStorage.setItem("@user_profile", profileJSON); ]
await AsyncStorage.setItem("@user_notifications", notificationsJSON); ];
AsyncStorage.multiSet(initialization).then(() => {
navigation.navigate("Feed"); navigation.navigate("Feed");
});
}; };
return ( return (