Separated user and auth stores

This commit is contained in:
Jori Lallo
2017-05-29 19:08:03 -07:00
parent 98a5283e27
commit 0d87d6abf5
12 changed files with 191 additions and 143 deletions

View File

@ -45,15 +45,17 @@ type AuthProps = {
};
const Auth = ({ children }: AuthProps) => {
if (stores.user.authenticated && stores.user.team) {
if (stores.auth.authenticated && stores.auth.team) {
// Only initialize stores once. Kept in global scope
// because otherwise they will get overriden on route
// change
if (!authenticatedStores) {
// Stores for authenticated user
const user = stores.auth.getUserStore();
authenticatedStores = {
user,
collections: new CollectionsStore({
teamId: stores.user.team.id,
teamId: user.team.id,
}),
};