Skip to content

Commit a1dbc74

Browse files
authored
fix(auth): unWatchUserProfile error when database is not setup (prescottprue#1042) - @ssdns
1 parent 260bf21 commit a1dbc74

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/actions/auth.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,20 @@ export function unWatchUserProfile(firebase) {
3737
authUid,
3838
config: { userProfile, useFirestoreForProfile }
3939
} = firebase._
40-
if (firebase._.profileWatch) {
41-
if (useFirestoreForProfile && firebase.firestore) {
42-
// Call profile onSnapshot unsubscribe stored on profileWatch
43-
firebase._.profileWatch()
44-
} else {
45-
firebase
46-
.database()
47-
.ref()
48-
.child(`${userProfile}/${authUid}`)
49-
.off('value', firebase._.profileWatch)
50-
}
51-
firebase._.profileWatch = null
40+
if (!firebase._.profileWatch) {
41+
return
42+
}
43+
if (useFirestoreForProfile && firebase.firestore) {
44+
// Call profile onSnapshot unsubscribe stored on profileWatch
45+
firebase._.profileWatch()
46+
} else if (userProfile && firebase.database) {
47+
firebase
48+
.database()
49+
.ref()
50+
.child(`${userProfile}/${authUid}`)
51+
.off('value', firebase._.profileWatch)
5252
}
53+
firebase._.profileWatch = null
5354
}
5455

5556
/**

0 commit comments

Comments
 (0)