Skip to content

Commit b6423f1

Browse files
committed
codeclimate: decrease cognitive complexity
1 parent fa2ec86 commit b6423f1

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/actions/auth.js

Lines changed: 13 additions & 12 deletions
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 if (firebase.database && userProfile) {
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)