Skip to content

Commit

Permalink
Fixed breakage if user not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
rioam2 committed Apr 29, 2018
1 parent fc6fc1b commit e6f4a53
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/firebase-redux/actions/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ const database = {
* field. Can be any datatype.
*/
set: (fieldString, value) => {
const [store, ...fieldpath] = fieldString.split('.');
const field = firestoreDB.doc(
`/users/${firebaseDB.auth().currentUser.uid}/${store}/data`
);
field.update({
[`${fieldpath.join('.')}`]: value
});
if (firebaseDB.auth().currentUser) {
const [store, ...fieldpath] = fieldString.split('.');
const field = firestoreDB.doc(
`/users/${firebaseDB.auth().currentUser.uid}/${store}/data`
);
field.update({
[`${fieldpath.join('.')}`]: value
});
}
},

/**
Expand Down

0 comments on commit e6f4a53

Please sign in to comment.